related to fix #24 - reinserted NULL checks on return values and ensured that all duped memory was freed upon errors.
authorKrista Grothoff <krista@pep-project.org>
Sun, 17 Jul 2016 11:51:49 +0200
changeset 89579a4cc341524
parent 894 e4d4d4e677a8
child 896 f07f9ebea462
related to fix #24 - reinserted NULL checks on return values and ensured that all duped memory was freed upon errors.
src/stringlist.c
src/stringpair.c
     1.1 --- a/src/stringlist.c	Sun Jul 17 11:45:36 2016 +0200
     1.2 +++ b/src/stringlist.c	Sun Jul 17 11:51:49 2016 +0200
     1.3 @@ -41,6 +41,10 @@
     1.4      
     1.5      while (src_curr) {
     1.6          *dst_curr_ptr = new_stringlist(src_curr->value);
     1.7 +        if (*dst_curr_ptr == NULL) {
     1.8 +            free_stringlist(dst);
     1.9 +            return NULL;
    1.10 +        }
    1.11          src_curr = src_curr->next;
    1.12          dst_curr_ptr = &((*dst_curr_ptr)->next);
    1.13      }
     2.1 --- a/src/stringpair.c	Sun Jul 17 11:45:36 2016 +0200
     2.2 +++ b/src/stringpair.c	Sun Jul 17 11:51:49 2016 +0200
     2.3 @@ -85,7 +85,16 @@
     2.4  
     2.5      while (src_curr) {
     2.6          copy_pair = stringpair_dup(src_curr->value);
     2.7 +        if (copy_pair == NULL) {
     2.8 +            free_stringpair_list(dst);
     2.9 +            return NULL;
    2.10 +        }
    2.11          *dst_curr_ptr = new_stringpair_list(copy_pair);
    2.12 +        if (*dst_curr_ptr == NULL) {
    2.13 +            free_stringpair(copy_pair);
    2.14 +            free_stringpair_list(dst);
    2.15 +            return NULL;
    2.16 +        }
    2.17          src_curr = src_curr->next;
    2.18          dst_curr_ptr = &((*dst_curr_ptr)->next);
    2.19      }