Commit a25c5dbb authored by Michael Niedermayer's avatar Michael Niedermayer

ffmpeg_opt: Fix memleaks in "manually set programs" loop

Fixes CID1351356, CID1351357
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 35d9441f
...@@ -2366,18 +2366,25 @@ loop_end: ...@@ -2366,18 +2366,25 @@ loop_end:
while(*p) { while(*p) {
const char *p2 = av_get_token(&p, ":"); const char *p2 = av_get_token(&p, ":");
const char *to_dealloc = p2;
char *key; char *key;
if (!p2) if (!p2)
break; break;
if(*p) p++; if(*p) p++;
key = av_get_token(&p2, "="); key = av_get_token(&p2, "=");
if (!key || !*p2) if (!key || !*p2) {
av_freep(&to_dealloc);
av_freep(&key);
break; break;
}
p2++; p2++;
if (!strcmp(key, "program_num")) if (!strcmp(key, "program_num"))
progid = strtol(p2, NULL, 0); progid = strtol(p2, NULL, 0);
av_freep(&to_dealloc);
av_freep(&key);
} }
program = av_new_program(oc, progid); program = av_new_program(oc, progid);
...@@ -2385,6 +2392,7 @@ loop_end: ...@@ -2385,6 +2392,7 @@ loop_end:
p = o->program[i].u.str; p = o->program[i].u.str;
while(*p) { while(*p) {
const char *p2 = av_get_token(&p, ":"); const char *p2 = av_get_token(&p, ":");
const char *to_dealloc = p2;
char *key; char *key;
if (!p2) if (!p2)
break; break;
...@@ -2411,6 +2419,8 @@ loop_end: ...@@ -2411,6 +2419,8 @@ loop_end:
av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key); av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
exit_program(1); exit_program(1);
} }
av_freep(&to_dealloc);
av_freep(&key);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment