diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-23 19:23:44 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-23 19:23:44 +0300 |
commit | ed8f56ba38ef8b36b1340a5bc5cbe5c85cfff966 (patch) | |
tree | de679f743a8b0412614bd09e2ea65eeb47b5a013 /swaybar/tray/icon.c | |
parent | Merge pull request #1244 from her001/swaylock-man-corrections (diff) | |
download | sway-ed8f56ba38ef8b36b1340a5bc5cbe5c85cfff966.tar.gz sway-ed8f56ba38ef8b36b1340a5bc5cbe5c85cfff966.tar.zst sway-ed8f56ba38ef8b36b1340a5bc5cbe5c85cfff966.zip |
Handle getline failure in icon theme parsing
Diffstat (limited to 'swaybar/tray/icon.c')
-rw-r--r-- | swaybar/tray/icon.c | 14 |
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) { | |||
49 | 49 | ||
50 | char *buf = NULL; | 50 | char *buf = NULL; |
51 | size_t n = 0; | 51 | size_t n = 0; |
52 | while (!feof(index)) { | 52 | while (!feof(index) && getline(&buf, &n, index) != -1) { |
53 | getline(&buf, &n, index); | ||
54 | if (n <= sizeof(inherits) + 1) { | 53 | if (n <= sizeof(inherits) + 1) { |
55 | continue; | 54 | continue; |
56 | } | 55 | } |
@@ -247,9 +246,8 @@ static list_t* find_theme_subdirs(const char *theme_dir) { | |||
247 | 246 | ||
248 | char *buf = NULL; | 247 | char *buf = NULL; |
249 | size_t n = 0; | 248 | size_t n = 0; |
250 | while (!feof(index)) { | 249 | const char directories[] = "Directories"; |
251 | const char directories[] = "Directories"; | 250 | while (!feof(index) && getline(&buf, &n, index) != -1) { |
252 | getline(&buf, &n, index); | ||
253 | if (n <= sizeof(directories) + 1) { | 251 | if (n <= sizeof(directories) + 1) { |
254 | continue; | 252 | continue; |
255 | } | 253 | } |
@@ -261,10 +259,8 @@ static list_t* find_theme_subdirs(const char *theme_dir) { | |||
261 | } | 259 | } |
262 | // Now, find the size of each dir | 260 | // Now, find the size of each dir |
263 | struct subdir *current_subdir = NULL; | 261 | struct subdir *current_subdir = NULL; |
264 | while (!feof(index)) { | 262 | const char size[] = "Size"; |
265 | const char size[] = "Size"; | 263 | while (!feof(index) && getline(&buf, &n, index) != -1) { |
266 | getline(&buf, &n, index); | ||
267 | |||
268 | if (buf[0] == '[') { | 264 | if (buf[0] == '[') { |
269 | int len = strlen(buf); | 265 | int len = strlen(buf); |
270 | if (buf[len-1] == '\n') { | 266 | if (buf[len-1] == '\n') { |