s4-registry: Don't leak memory on error.
[metze/samba/wip.git] / 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;
                }