From 534fe740f56a138fb234194cf555293cc4ab60ea Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 31 Aug 2006 22:45:20 +0000 Subject: [PATCH] Bugfix: potential write of unallocated memory. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19618 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 0a6c027eeb..e44cd53c45 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -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);