libdvbv5/parse_string: don't free twice
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 15 Nov 2013 12:27:13 +0000 (10:27 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 27 Nov 2013 11:24:16 +0000 (09:24 -0200)
As reported by valgrind, sometimes, it was freeing the same
data twice, with was causing random troubles elsewhere.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/libdvbv5/parse_string.c

index 78c1cea..f7b745e 100644 (file)
@@ -485,7 +485,10 @@ void parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
                *dest = realloc(*dest, strlen(*dest) + 1);
 
        if (!len2) {
-               free (tmp2);
+               if (tmp2) {
+                       free (tmp2);
+                       tmp2 = NULL;
+               }
                free (*emph);
                *emph = NULL;
        } else {
@@ -493,7 +496,9 @@ void parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
                *emph = realloc(*emph, strlen(*emph) + 1);
        }
 
-       free(tmp1);
-       free(tmp2);
+       if (tmp1)
+               free(tmp1);
+       if (tmp2)
+               free(tmp2);
 }