copy_vector: plug memory leak in error path

Only the array was being freed, not the contents.
GitHub issue #202.
This commit is contained in:
Todd C. Miller
2022-11-18 07:19:47 -07:00
parent 981cc2f8e3
commit 9c694e9a65

View File

@@ -96,7 +96,7 @@ copy_vector(char * const *src)
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
copy[i] = sudo_mmap_strdup(src[i]); copy[i] = sudo_mmap_strdup(src[i]);
if (copy[i] == NULL) { if (copy[i] == NULL) {
sudo_mmap_free(copy); free_vector(copy);
debug_return_ptr(NULL); debug_return_ptr(NULL);
} }
} }