explicit null checks are cool
This commit is contained in:
parent
f89e3e56c6
commit
794789e01f
@ -414,13 +414,13 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char*
|
|||||||
if (fp_labeltext == NULL) {
|
if (fp_labeltext == NULL) {
|
||||||
fprintf(stderr, "error executing '%s'\n", cmd_labeltext);
|
fprintf(stderr, "error executing '%s'\n", cmd_labeltext);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if (fgets(line, sizeof(line), fp_labeltext)) {
|
} else if (fgets(line, sizeof(line), fp_labeltext) != NULL) {
|
||||||
// lastly, read the output of said command, and put it into the text variable to be used for the label widgets
|
// lastly, read the output of said command, and put it into the text variable to be used for the label widgets
|
||||||
// consider using 'printf %.10s as your --pre-display-cmd to limit a string to a determined width. 10 here is an example
|
// consider using 'printf %.10s as your --pre-display-cmd to limit a string to a determined width. 10 here is an example
|
||||||
size += strlen(line+1); // we need place for the \0 of strcpy
|
size += strlen(line+1); // we need place for the \0 of strcpy
|
||||||
text = (char *) realloc(text, size);
|
text = (char *) realloc(text, size);
|
||||||
strcpy(text, line);
|
strcpy(text, line);
|
||||||
while (fgets(line, sizeof(line), fp_labeltext)) {
|
while (fgets(line, sizeof(line), fp_labeltext) != NULL) {
|
||||||
size += strlen(line);
|
size += strlen(line);
|
||||||
text = (char *) realloc(text, size);
|
text = (char *) realloc(text, size);
|
||||||
strncat(text, line, size);
|
strncat(text, line, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user