summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:37:36 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:37:36 +0100
commit838d28ab5d5a3c9177e43e66df088f70cc243303 (patch)
treeb9fed186bf1bd57adaddab4893b6be91a2df3a7d /src
parent3aab77ce8a8b884d0575ba0f66398b0303936774 (diff)
downloadratpoison-838d28ab5d5a3c9177e43e66df088f70cc243303.zip
Fix cmd_getsel when there is no X selection
* instead of feeding stdio a NULL string and invoking undefined behavior, return a failure
Diffstat (limited to 'src')
-rw-r--r--src/actions.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/actions.c b/src/actions.c
index 3b2692e..7e4fdc3 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -5962,11 +5962,17 @@ cmd_putsel (int interactive UNUSED, struct cmdarg **args)
cmdret *
cmd_getsel (int interactive UNUSED, struct cmdarg **args UNUSED)
{
- char *sel = get_selection();
+ char *sel;
cmdret *ret;
- ret = cmdret_new (RET_SUCCESS, "%s", sel);
- free (sel);
- return ret;
+ sel = get_selection();
+ if (sel != NULL)
+ {
+ ret = cmdret_new (RET_SUCCESS, "%s", sel);
+ free (sel);
+ return ret;
+ }
+ else
+ return cmdret_new (RET_FAILURE, "getsel: no X11 selection");
}
/* This is a command that restores old commands that have been