summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libass/ass.c8
1 files 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);