Permalink
Browse files

Fixed another mem leak

  • Loading branch information...
1 parent 42ba034 commit 28884b52a8d42d992b6bbacbc8d7397aa4a84b2a @antirez committed Jul 7, 2010
Showing with 2 additions and 3 deletions.
  1. +2 −3 linenoise.c
View
@@ -219,11 +219,10 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
if (nread <= 0) return len;
switch(c) {
case 13: /* enter */
- history_len--;
- return len;
case 4: /* ctrl-d */
history_len--;
- return (len == 0) ? -1 : (int)len;
+ free(history[history_len]);
+ return (len == 0 && c == 4) ? -1 : (int)len;
case 3: /* ctrl-c */
errno = EAGAIN;
return -1;

0 comments on commit 28884b5

Please sign in to comment.