summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2020-10-13 03:14:28 +0200
committerOleg Oshmyan <chortos@inbox.lv>2020-10-27 01:03:04 +0200
commit324c75fb6972d42b707aa17edc38b9943ae966bd (patch)
treeeaef1422060382a950650ba99fb4f94cbb81c33d /libass
parent660024f12e33b1e7b5df377ddf2c5ecb3609ebb7 (diff)
downloadlibass-324c75fb6972d42b707aa17edc38b9943ae966bd.tar.bz2
libass-324c75fb6972d42b707aa17edc38b9943ae966bd.tar.xz
Check for strdup_failures in process_style
We can't parse the style without a valid style_format. If strdup for FontName or Name or there fallback values fails, the style is of no use, so discard it. As the removal happens before any other styles are added, just decreasing n_styles is safe here.
Diffstat (limited to 'libass')
-rw-r--r--libass/ass.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libass/ass.c b/libass/ass.c
index 960fee1..370afb8 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -488,9 +488,13 @@ static int process_style(ASS_Track *track, char *str)
track->style_format = strdup(ssa_style_format);
else
track->style_format = strdup(ass_style_format);
+ if (!track->style_format)
+ return -1;
}
q = format = strdup(track->style_format);
+ if (!q)
+ return -1;
ass_msg(track->library, MSGL_V, "[%p] Style: %s", track, str);
@@ -511,8 +515,6 @@ static int process_style(ASS_Track *track, char *str)
PARSE_START
STARREDSTRVAL(Name)
- if (strcmp(target->Name, "Default") == 0)
- track->default_style = sid;
STRVAL(FontName)
COLORVAL(PrimaryColour)
COLORVAL(SecondaryColour)
@@ -548,6 +550,7 @@ static int process_style(ASS_Track *track, char *str)
FPVAL(Shadow)
PARSE_END
}
+ free(format);
style->ScaleX = FFMAX(style->ScaleX, 0.) / 100.;
style->ScaleY = FFMAX(style->ScaleY, 0.) / 100.;
style->Spacing = FFMAX(style->Spacing, 0.);
@@ -561,7 +564,13 @@ static int process_style(ASS_Track *track, char *str)
style->Name = strdup("Default");
if (!style->FontName)
style->FontName = strdup("Arial");
- free(format);
+ if (!style->Name || !style->FontName) {
+ ass_free_style(track, sid);
+ track->n_styles--;
+ return -1;
+ }
+ if (strcmp(target->Name, "Default") == 0)
+ track->default_style = sid;
return 0;
}