diff options
-rw-r--r-- | common/readline.c | 3 | ||||
-rw-r--r-- | sway/config.c | 3 | ||||
-rw-r--r-- | sway/main.c | 15 |
3 files changed, 18 insertions, 3 deletions
diff --git a/common/readline.c b/common/readline.c index 5106172c..cc40a2cc 100644 --- a/common/readline.c +++ b/common/readline.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "readline.h" | 1 | #include "readline.h" |
2 | #include "log.h" | ||
2 | #include <stdlib.h> | 3 | #include <stdlib.h> |
3 | #include <stdio.h> | 4 | #include <stdio.h> |
4 | 5 | ||
@@ -7,6 +8,7 @@ char *read_line(FILE *file) { | |||
7 | char *string = malloc(size); | 8 | char *string = malloc(size); |
8 | char lastChar = '\0'; | 9 | char lastChar = '\0'; |
9 | if (!string) { | 10 | if (!string) { |
11 | sway_log(L_ERROR, "Unable to allocate memory for read_line"); | ||
10 | return NULL; | 12 | return NULL; |
11 | } | 13 | } |
12 | while (1) { | 14 | while (1) { |
@@ -27,6 +29,7 @@ char *read_line(FILE *file) { | |||
27 | char *new_string = realloc(string, size *= 2); | 29 | char *new_string = realloc(string, size *= 2); |
28 | if (!new_string) { | 30 | if (!new_string) { |
29 | free(string); | 31 | free(string); |
32 | sway_log(L_ERROR, "Unable to allocate memory for read_line"); | ||
30 | return NULL; | 33 | return NULL; |
31 | } | 34 | } |
32 | string = new_string; | 35 | string = new_string; |
diff --git a/sway/config.c b/sway/config.c index e737f83c..98109937 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -575,6 +575,9 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
575 | char *line; | 575 | char *line; |
576 | while (!feof(file)) { | 576 | while (!feof(file)) { |
577 | line = read_line(file); | 577 | line = read_line(file); |
578 | if (!line) { | ||
579 | continue; | ||
580 | } | ||
578 | line_number++; | 581 | line_number++; |
579 | line = strip_whitespace(line); | 582 | line = strip_whitespace(line); |
580 | if (line[0] == '#') { | 583 | if (line[0] == '#') { |
diff --git a/sway/main.c b/sway/main.c index 157c61b3..d41eb292 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -53,7 +53,10 @@ void detect_proprietary() { | |||
53 | return; | 53 | return; |
54 | } | 54 | } |
55 | while (!feof(f)) { | 55 | while (!feof(f)) { |
56 | char *line = read_line(f); | 56 | char *line; |
57 | if (!(line = read_line(f))) { | ||
58 | break; | ||
59 | } | ||
57 | if (strstr(line, "nvidia")) { | 60 | if (strstr(line, "nvidia")) { |
58 | fprintf(stderr, "\x1B[1;31mWarning: Proprietary nvidia drivers do NOT support Wayland. Use nouveau.\x1B[0m\n"); | 61 | fprintf(stderr, "\x1B[1;31mWarning: Proprietary nvidia drivers do NOT support Wayland. Use nouveau.\x1B[0m\n"); |
59 | fprintf(stderr, "\x1B[1;31mYes, they STILL don't work with the newly announced wayland \"support\".\x1B[0m\n"); | 62 | fprintf(stderr, "\x1B[1;31mYes, they STILL don't work with the newly announced wayland \"support\".\x1B[0m\n"); |
@@ -118,7 +121,10 @@ static void log_distro() { | |||
118 | if (f) { | 121 | if (f) { |
119 | sway_log(L_INFO, "Contents of %s:", paths[i]); | 122 | sway_log(L_INFO, "Contents of %s:", paths[i]); |
120 | while (!feof(f)) { | 123 | while (!feof(f)) { |
121 | char *line = read_line(f); | 124 | char *line; |
125 | if (!(line = read_line(f))) { | ||
126 | break; | ||
127 | } | ||
122 | if (*line) { | 128 | if (*line) { |
123 | sway_log(L_INFO, "%s", line); | 129 | sway_log(L_INFO, "%s", line); |
124 | } | 130 | } |
@@ -136,7 +142,10 @@ static void log_kernel() { | |||
136 | return; | 142 | return; |
137 | } | 143 | } |
138 | while (!feof(f)) { | 144 | while (!feof(f)) { |
139 | char *line = read_line(f); | 145 | char *line; |
146 | if (!(line = read_line(f))) { | ||
147 | break; | ||
148 | } | ||
140 | if (*line) { | 149 | if (*line) { |
141 | sway_log(L_INFO, "%s", line); | 150 | sway_log(L_INFO, "%s", line); |
142 | } | 151 | } |