summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>2018-03-19 13:46:05 +0900
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-03-19 07:45:20 +0200
commit5aa0dd42f7b45b5ef2bceb8510aeb2a892866abf (patch)
tree4f8b8715cb8929f8c269e5b9d1da9e214168113d
parent1c1f807c304a77ae4965f00ccee04fdbe7415d5e (diff)
downloadbluez-5aa0dd42f7b45b5ef2bceb8510aeb2a892866abf.tar.gz
shared/shell: Return NULL if generator error occur
Explicitly returns NULL if asprintf() fails, since the asprintf(3) man-page says that the contents of the first argument are undefined if any error occurs.
-rw-r--r--src/shared/shell.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/shell.c b/src/shared/shell.c
index 0a05b5215..7417e7ab4 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -643,8 +643,13 @@ static char *cmd_generator(const char *text, int state)
}
cmd = find_cmd(text + strlen(menu->name) + 1, menu->entries, &index);
- if (cmd)
- asprintf(&cmd, "%s.%s", menu->name, cmd);
+ if (cmd) {
+ int err;
+
+ err = asprintf(&cmd, "%s.%s", menu->name, cmd);
+ if (err < 0)
+ return NULL;
+ }
return cmd;
}