Browse Source

related to fix #24 - reinserted NULL checks on return values and ensured that all duped memory was freed upon errors.

doc_update_sequoia
Krista Grothoff 6 years ago
parent
commit
f73d4ed9ce
2 changed files with 13 additions and 0 deletions
  1. +4
    -0
      src/stringlist.c
  2. +9
    -0
      src/stringpair.c

+ 4
- 0
src/stringlist.c View File

@ -41,6 +41,10 @@ DYNAMIC_API stringlist_t *stringlist_dup(const stringlist_t *src)
while (src_curr) {
*dst_curr_ptr = new_stringlist(src_curr->value);
if (*dst_curr_ptr == NULL) {
free_stringlist(dst);
return NULL;
}
src_curr = src_curr->next;
dst_curr_ptr = &((*dst_curr_ptr)->next);
}


+ 9
- 0
src/stringpair.c View File

@ -85,7 +85,16 @@ DYNAMIC_API stringpair_list_t *stringpair_list_dup(
while (src_curr) {
copy_pair = stringpair_dup(src_curr->value);
if (copy_pair == NULL) {
free_stringpair_list(dst);
return NULL;
}
*dst_curr_ptr = new_stringpair_list(copy_pair);
if (*dst_curr_ptr == NULL) {
free_stringpair(copy_pair);
free_stringpair_list(dst);
return NULL;
}
src_curr = src_curr->next;
dst_curr_ptr = &((*dst_curr_ptr)->next);
}


Loading…
Cancel
Save