summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-06-23 12:28:14 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-06-29 13:25:54 -0400
commitcb52454945fe9c23635c775e3804eaab56b5c086 (patch)
treefd4ff4b7e1f4779a5585f4fd98bb461ae6a1ce4c
parentMerge pull request #1244 from her001/swaylock-man-corrections (diff)
downloadsway-cb52454945fe9c23635c775e3804eaab56b5c086.tar.gz
sway-cb52454945fe9c23635c775e3804eaab56b5c086.tar.zst
sway-cb52454945fe9c23635c775e3804eaab56b5c086.zip
Merge pull request #1251 from Hummer12007/icons
Handle getline failure in icon theme parsing
-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) {
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') {