summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-10 08:17:35 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-10 08:17:35 +0200
commit9c95991fcefa80ab54e3bc39aa3b66f2b44d05f0 (patch)
tree9b34b84e61afa402477d07295bc2b47667163896
parentb512806d40ca771ce9ee74b47e5a828ad6039e7c (diff)
downloadratpoison-9c95991fcefa80ab54e3bc39aa3b66f2b44d05f0.zip
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
-rw-r--r--src/actions.c8
1 files changed, 6 insertions, 2 deletions
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;
}