Skip to content
Snippets Groups Projects
Commit 94459f99 authored by florian.burgener's avatar florian.burgener
Browse files

Fix memory leak

parent 67140dbe
No related branches found
No related tags found
No related merge requests found
...@@ -140,7 +140,9 @@ char *hm_rm(hm_t *hm, const char *const key) { ...@@ -140,7 +140,9 @@ char *hm_rm(hm_t *hm, const char *const key) {
entry_before->next = entry_before->next->next; entry_before->next = entry_before->next->next;
} }
char *value = entry->value; char *value = strdup(entry->value);
free(entry->key);
free(entry->value);
free(entry); free(entry);
return value; return value;
} }
......
...@@ -47,7 +47,8 @@ int main() { ...@@ -47,7 +47,8 @@ int main() {
scanf("%s", key); scanf("%s", key);
clear_buffer(); clear_buffer();
hm_rm(hm, key); char *c = hm_rm(hm, key);
free(c);
} else if (action == 4) { } else if (action == 4) {
printf("Phone Number: "); printf("Phone Number: ");
scanf("%s", key); scanf("%s", key);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment