changeset 19612:dcd0f218008f

Bugfix: potential write of unallocated memory.
author eugeni
date Thu, 31 Aug 2006 22:45:20 +0000
parents 27c747718955
children 7d75865fdda9
files libass/ass.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);