write_history(), read_history(): Check fclose() return value

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2017-11-29 21:40:38 +01:00
parent 621f126128
commit ea79fe70f9

View File

@ -1070,7 +1070,8 @@ static void hist_add(const char *p)
return; return;
#endif #endif
if ((s = strdup(p)) == NULL) s = strdup(p);
if (s == NULL)
return; return;
if (H.Size < el_hist_size) { if (H.Size < el_hist_size) {
@ -1337,9 +1338,8 @@ int read_history(const char *filename)
buf[strlen(buf) - 1] = 0; /* Remove '\n' */ buf[strlen(buf) - 1] = 0; /* Remove '\n' */
add_history(buf); add_history(buf);
} }
fclose(fp);
return 0; return fclose(fp);
} }
return errno; return errno;
@ -1357,9 +1357,7 @@ int write_history(const char *filename)
while (i < H.Size) while (i < H.Size)
fprintf(fp, "%s\n", H.Lines[i++]); fprintf(fp, "%s\n", H.Lines[i++]);
fclose(fp); return fclose(fp);
return 0;
} }
return errno; return errno;