aboutsummaryrefslogtreecommitdiff
path: root/swaybar/tray
diff options
context:
space:
mode:
authorMykyta Holubakha <hilobakho@gmail.com>2017-06-23 19:23:44 +0300
committerMykyta Holubakha <hilobakho@gmail.com>2017-06-23 19:23:44 +0300
commited8f56ba38ef8b36b1340a5bc5cbe5c85cfff966 (patch)
treede679f743a8b0412614bd09e2ea65eeb47b5a013 /swaybar/tray
parent9ae3b2fb0b3b7405556b3c52344cf256e73f632b (diff)
Handle getline failure in icon theme parsing
Diffstat (limited to 'swaybar/tray')
-rw-r--r--swaybar/tray/icon.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index 29151a74..1c69ba72 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -49,8 +49,7 @@ static list_t *find_inherits(const char *theme_dir) {
char *buf = NULL;
size_t n = 0;
- while (!feof(index)) {
- getline(&buf, &n, index);
+ while (!feof(index) && getline(&buf, &n, index) != -1) {
if (n <= sizeof(inherits) + 1) {
continue;
}
@@ -247,9 +246,8 @@ static list_t* find_theme_subdirs(const char *theme_dir) {
char *buf = NULL;
size_t n = 0;
- while (!feof(index)) {
- const char directories[] = "Directories";
- getline(&buf, &n, index);
+ const char directories[] = "Directories";
+ while (!feof(index) && getline(&buf, &n, index) != -1) {
if (n <= sizeof(directories) + 1) {
continue;
}
@@ -261,10 +259,8 @@ static list_t* find_theme_subdirs(const char *theme_dir) {
}
// Now, find the size of each dir
struct subdir *current_subdir = NULL;
- while (!feof(index)) {
- const char size[] = "Size";
- getline(&buf, &n, index);
-
+ const char size[] = "Size";
+ while (!feof(index) && getline(&buf, &n, index) != -1) {
if (buf[0] == '[') {
int len = strlen(buf);
if (buf[len-1] == '\n') {