ffmpeg_opt: Fix memleaks in "manually set programs" loop
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 8 Feb 2016 14:23:51 +0000 (15:23 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 8 Feb 2016 14:57:24 +0000 (15:57 +0100)
Fixes CID1351356, CID1351357

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
ffmpeg_opt.c

index 669976b..bc8355e 100644 (file)
@@ -2366,18 +2366,25 @@ loop_end:
 
         while(*p) {
             const char *p2 = av_get_token(&p, ":");
+            const char *to_dealloc = p2;
             char *key;
             if (!p2)
                 break;
+
             if(*p) p++;
 
             key = av_get_token(&p2, "=");
-            if (!key || !*p2)
+            if (!key || !*p2) {
+                av_freep(&to_dealloc);
+                av_freep(&key);
                 break;
+            }
             p2++;
 
             if (!strcmp(key, "program_num"))
                 progid = strtol(p2, NULL, 0);
+            av_freep(&to_dealloc);
+            av_freep(&key);
         }
 
         program = av_new_program(oc, progid);
@@ -2385,6 +2392,7 @@ loop_end:
         p = o->program[i].u.str;
         while(*p) {
             const char *p2 = av_get_token(&p, ":");
+            const char *to_dealloc = p2;
             char *key;
             if (!p2)
                 break;
@@ -2411,6 +2419,8 @@ loop_end:
                 av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
                 exit_program(1);
             }
+            av_freep(&to_dealloc);
+            av_freep(&key);
         }
     }