]> granicus.if.org Git - libass/commitdiff
Bugfix: potential write of unallocated memory.
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 31 Aug 2006 22:45:20 +0000 (22:45 +0000)
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 31 Aug 2006 22:45:20 +0000 (22:45 +0000)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19618 b3059339-0415-0410-9bf9-f77b7e298cf2

libass/ass.c

index 0a6c027eeb4bfc9b0efaf1c04cb73c11d9ef4aa2..e44cd53c45a9b006bbdd405c301868719d00eb23 100644 (file)
@@ -282,9 +282,11 @@ static int process_event_tail(ass_track_t* track, ass_event_t* event, char* str,
                if (strcasecmp(tname, "Text") == 0) {
                        char* last;
                        event->Text = strdup(p);
-                       last = event->Text + strlen(event->Text) - 1;
-                       if (*last == '\r')
-                               *last = 0;
+                       if (*event->Text != 0) {
+                               last = event->Text + strlen(event->Text) - 1;
+                               if (last >= event->Text && *last == '\r')
+                                       *last = 0;
+                       }
                        mp_msg(MSGT_GLOBAL, MSGL_DBG2, "Text = %s\n", event->Text);
                        event->Duration -= event->Start;
                        free(format);