# HG changeset patch # User eugeni # Date 1157064320 0 # Node ID dcd0f218008f341479dae9a5c9a374817189f136 # Parent 27c747718955e14ea3f324a2f90567bcab8efeb1 Bugfix: potential write of unallocated memory. diff -r 27c747718955 -r dcd0f218008f libass/ass.c --- a/libass/ass.c Thu Aug 31 21:26:02 2006 +0000 +++ b/libass/ass.c Thu Aug 31 22:45:20 2006 +0000 @@ -282,9 +282,11 @@ 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);