From patchwork Wed Jan 30 10:24:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [08/18] readline: Fix unchecked strdup() by converting to g_strdup() Date: Wed, 30 Jan 2013 00:24:20 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 216835 Message-Id: <1359541470-30775-13-git-send-email-stefanha@redhat.com> To: Cc: Anthony Liguori , Markus Armbruster , Stefan Hajnoczi From: Markus Armbruster Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- readline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readline.c b/readline.c index a0c9638..d6e04d4 100644 --- a/readline.c +++ b/readline.c @@ -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; }