From 9c95991fcefa80ab54e3bc39aa3b66f2b44d05f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Wed, 10 Apr 2013 08:17:35 +0200 Subject: cmd_prompt: handle NULL output * if the user aborted we receive a NULL pointer; don't attempt to dereference it, and treat this case as a failure. Matches the behaviour of cmd_colon and cmd_select --- src/actions.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index e61497e..fa5af52 100644 --- a/src/actions.c +++ b/src/actions.c @@ -5826,9 +5826,13 @@ cmd_prompt (int interactive UNUSED, struct cmdarg **args) output = get_input (ARG_STRING(0), hist_PROMPT, trivial_completions); } } + + if (output == NULL) + return cmdret_new (RET_FAILURE, NULL); /* User aborted */ + ret = cmdret_new (RET_SUCCESS, "%s", output); - if (output) - free (output); + free (output); + return ret; } -- cgit v1.2.3