Commit 21cf6e22 authored by Daniel Salzman's avatar Daniel Salzman

contents: fix error cleanup in zone_contents_new

parent 73f4c7fa
...@@ -144,12 +144,11 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name) ...@@ -144,12 +144,11 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name)
return NULL; return NULL;
} }
zone_contents_t *contents = malloc(sizeof(zone_contents_t)); zone_contents_t *contents = calloc(1, sizeof(*contents));
if (contents == NULL) { if (contents == NULL) {
return NULL; return NULL;
} }
memset(contents, 0, sizeof(zone_contents_t));
contents->apex = node_new(apex_name, NULL); contents->apex = node_new(apex_name, NULL);
if (contents->apex == NULL) { if (contents->apex == NULL) {
goto cleanup; goto cleanup;
...@@ -167,8 +166,8 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name) ...@@ -167,8 +166,8 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name)
return contents; return contents;
cleanup: cleanup:
node_free(contents->apex, NULL);
free(contents->nodes); free(contents->nodes);
free(contents->nsec3_nodes);
free(contents); free(contents);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment