s4-registry: Don't leak memory on error.
authorAndreas Schneider <asn@samba.org>
Wed, 20 Feb 2013 09:03:13 +0000 (10:03 +0100)
committerAlexander Bokovoy <ab@samba.org>
Fri, 22 Feb 2013 15:36:14 +0000 (16:36 +0100)
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source4/lib/registry/tools/regshell.c

index 1a4067bce35352beafa31b7edd172d7d61f1240a..dd154f78c94ed98bdd5a9c2e5fb7224a07f04f51 100644 (file)
@@ -508,8 +508,15 @@ static char **reg_complete_key(const char *text, int start, int end)
                } else if(W_ERROR_EQUAL(status, WERR_NO_MORE_ITEMS)) {
                        break;
                } else {
+                       int n;
+
                        printf("Error creating completion list: %s\n",
                                win_errstr(status));
+
+                       for (n = j; n >= 0; n--) {
+                               SAFE_FREE(matches[n]);
+                       }
+                       SAFE_FREE(matches);
                        talloc_free(mem_ctx);
                        return NULL;
                }