diff options
Diffstat (limited to 'src/m_argv.c')
-rw-r--r-- | src/m_argv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/m_argv.c b/src/m_argv.c index bdebd23..7661ef7 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -41,10 +41,11 @@ static char *m_get_prev_hist(t_msh *msh) return (NULL); if (stat(histfile, &sb) == -1) return (NULL); - if ((hist = (char*)malloc(sb.st_size * sizeof(char))) == NULL) + if ((hist = (char*)malloc((sb.st_size + 1) * sizeof(char))) == NULL) return (NULL); if (read(fd, hist, sb.st_size) == -1) return (NULL); + hist[sb.st_size] = C_NUL; return (hist); } |