From 97aded721dd0bf33a56839517921e4c7094c90d7 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Sun, 26 Jun 2022 22:55:32 +0100 Subject: Fix some minor memory error typos. --- src/history.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/history.c') diff --git a/src/history.c b/src/history.c index 99edf79..7e2a84b 100644 --- a/src/history.c +++ b/src/history.c @@ -82,13 +82,14 @@ struct history history_load() } errno = 0; - char *buf = xmalloc(len); + char *buf = xmalloc(len + 1); if (fread(buf, 1, len, histfile) != len) { log_error("Error reading history file: %s.\n", strerror(errno)); fclose(histfile); return vec; } fclose(histfile); + buf[len] = '\0'; char *saveptr = NULL; char *tok = strtok_r(buf, " ", &saveptr); -- cgit v1.2.3