Commit 0ba77657 authored by oggk's avatar oggk
Browse files

prevent dereferencing NULL if malloc returns NULL (blah blah MMU anyway blah)

parent 32ad71c4
......@@ -1263,20 +1263,26 @@ void ff2theora_output(ff2theora this) {
// SSA has control stuff in there, extract raw text
if (enc->codec_id == CODEC_ID_SSA) {
char *dupe = malloc(utf8len+1); // not zero terminated, so make it so
memcpy(dupe, utf8, utf8len);
dupe[utf8len] = 0;
duration = get_duration_from_ssa(dupe);
allocated_utf8 = get_raw_text_from_ssa(dupe);
if (allocated_utf8) {
if (allocated_utf8 == dupe) {
allocated_utf8 = NULL;
}
else {
utf8 = allocated_utf8;
utf8len = strlen(utf8);
if (dupe) {
memcpy(dupe, utf8, utf8len);
dupe[utf8len] = 0;
duration = get_duration_from_ssa(dupe);
allocated_utf8 = get_raw_text_from_ssa(dupe);
if (allocated_utf8) {
if (allocated_utf8 == dupe) {
allocated_utf8 = NULL;
}
else {
utf8 = allocated_utf8;
utf8len = strlen(utf8);
}
}
free(dupe);
}
else {
utf8 = NULL;
utf8len = 0;
}
free(dupe);
}
if (t < 0 && t + duration > 0) {
duration += t;
......
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