Skip to content

Commit

Permalink
readline: Fix unchecked strdup() by converting to g_strdup()
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Markus Armbruster authored and stefanhaRH committed Jan 30, 2013
1 parent d3f8e13 commit c3baa5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions readline.c
Expand Up @@ -247,14 +247,14 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
}
if (idx == READLINE_MAX_CMDS) {
/* Need to get one free slot */
free(rs->history[0]);
g_free(rs->history[0]);
memmove(rs->history, &rs->history[1],
(READLINE_MAX_CMDS - 1) * sizeof(char *));
rs->history[READLINE_MAX_CMDS - 1] = NULL;
idx = READLINE_MAX_CMDS - 1;
}
if (new_entry == NULL)
new_entry = strdup(cmdline);
new_entry = g_strdup(cmdline);
rs->history[idx] = new_entry;
rs->hist_entry = -1;
}
Expand Down

0 comments on commit c3baa5f

Please sign in to comment.