[xiph-commits] r16064 - trunk/ffmpeg2theora/src

oggk at svn.xiph.org oggk at svn.xiph.org
Sun May 31 03:02:45 PDT 2009


Author: oggk
Date: 2009-05-31 03:02:45 -0700 (Sun, 31 May 2009)
New Revision: 16064

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
prevent dereferencing NULL if malloc returns NULL (blah blah MMU anyway blah)



Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-05-31 09:57:37 UTC (rev 16063)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-05-31 10:02:45 UTC (rev 16064)
@@ -1263,20 +1263,26 @@
                   // 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;
+                    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);
+                        }
                       }
-                      else {
-                        utf8 = allocated_utf8;
-                        utf8len = strlen(utf8);
-                      }
+                      free(dupe);
                     }
-                    free(dupe);
+                    else {
+                      utf8 = NULL;
+                      utf8len = 0;
+                    }
                   }
                   if (t < 0 && t + duration > 0) {
                     duration += t;



More information about the commits mailing list