From: Michael Adam Date: Tue, 5 Apr 2016 13:43:52 +0000 (+0200) Subject: s4:regshell: fix O3 error unused result of asprintf in reg_complete_key() X-Git-Tag: tdb-1.3.10~1181 X-Git-Url: http://git.samba.org/samba.git/?p=bbaumbach%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=a6db0527cbb606fea7263f99cf496e5faa9529a0 s4:regshell: fix O3 error unused result of asprintf in reg_complete_key() Signed-off-by: Michael Adam Reviewed-by: Christian Ambach --- diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 448f9576e0a..6b61c92707b 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -482,6 +482,7 @@ static char **reg_complete_key(const char *text, int start, int end) const char *base_n = ""; TALLOC_CTX *mem_ctx; WERROR status; + int ret; matches = malloc_array_p(char *, MAX_COMPLETIONS); if (!matches) return NULL; @@ -529,12 +530,16 @@ static char **reg_complete_key(const char *text, int start, int end) } if (j == 2) { /* Exact match */ - asprintf(&matches[0], "%s%s", base_n, matches[1]); + ret = asprintf(&matches[0], "%s%s", base_n, matches[1]); } else { - asprintf(&matches[0], "%s%s", base_n, + ret = asprintf(&matches[0], "%s%s", base_n, talloc_strndup(mem_ctx, matches[1], samelen)); } talloc_free(mem_ctx); + if (ret == -1) { + SAFE_FREE(matches); + return NULL; + } matches[j] = NULL; return matches;