fix #95 : Double free - Incorrect memory allocation in stringpair_list_append()
authorEdouard Tisserant
Sat, 09 Jul 2016 15:20:23 +0200
changeset 812786f03e0cae4
parent 806 3c66f5d8cfb3
child 813 2f069faaf513
fix #95 : Double free - Incorrect memory allocation in stringpair_list_append()
src/stringpair.c
     1.1 --- a/src/stringpair.c	Fri Jul 08 21:34:32 2016 +0200
     1.2 +++ b/src/stringpair.c	Sat Jul 09 15:20:23 2016 +0200
     1.3 @@ -123,9 +123,14 @@
     1.4      stringpair_list_t *_s = stringpair_list;
     1.5      stringpair_list_t *_s2;
     1.6      for (_s2 = second; _s2 != NULL; _s2 = _s2->next) {
     1.7 -        _s = stringpair_list_add(_s, _s2->value);
     1.8 -        if (_s == NULL)
     1.9 +        stringpair_t *_sp = stringpair_dup(_s2->value);
    1.10 +        if (_sp == NULL)
    1.11              return NULL;
    1.12 +        _s = stringpair_list_add(_s, _sp);
    1.13 +        if (_s == NULL){
    1.14 +            free_stringpair(_sp);
    1.15 +            return NULL;
    1.16 +        }
    1.17      }
    1.18      return _s;
    1.19  }