summaryrefslogtreecommitdiff
path: root/src/history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/history.c b/src/history.c
index 4438b5d..99edf79 100644
--- a/src/history.c
+++ b/src/history.c
@@ -66,11 +66,14 @@ struct history history_load()
return vec;
}
+ errno = 0;
if (fseek(histfile, 0, SEEK_END) != 0) {
log_error("Error seeking in history file: %s.\n", strerror(errno));
fclose(histfile);
return vec;
}
+
+ errno = 0;
size_t len = ftell(histfile);
if (fseek(histfile, 0, SEEK_SET) != 0) {
log_error("Error seeking in history file: %s.\n", strerror(errno));
@@ -78,8 +81,9 @@ struct history history_load()
return vec;
}
+ errno = 0;
char *buf = xmalloc(len);
- if (fread(buf, 1, len, histfile) != 0) {
+ if (fread(buf, 1, len, histfile) != len) {
log_error("Error reading history file: %s.\n", strerror(errno));
fclose(histfile);
return vec;