s4:regshell: fix O3 error unused result of asprintf in reg_complete_key()
authorMichael Adam <obnox@samba.org>
Tue, 5 Apr 2016 13:43:52 +0000 (15:43 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 12 May 2016 22:16:16 +0000 (00:16 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
source4/lib/registry/tools/regshell.c

index 448f9576e0a463e30a7ef9a35a118edd91a8bc89..6b61c92707b4832014c0cdb1ba09de23c3273a26 100644 (file)
@@ -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;