summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-17 21:24:52 +0100
committerwm4 <wm4@nowhere>2014-11-17 21:24:52 +0100
commit1b2795913a99e5df799b272528dcf57e8d6fce3f (patch)
treea990abb094d346ecab018a01aa3e2476db41c917 /libass/ass_render.c
parent2f9467cfd2574af44f97ee89b460c410a5a3c85a (diff)
downloadlibass-1b2795913a99e5df799b272528dcf57e8d6fce3f.tar.bz2
libass-1b2795913a99e5df799b272528dcf57e8d6fce3f.tar.xz
More malloc checking
Use strndup() instead of malloc+copy. Make all code deal with the possibility that ASS_Drawing.text can be NULL (which can happen on allocation failure). Skip fix_collisions() on malloc failure - the lines will overlap, but at least libass won't crash.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r--libass/ass_render.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index b88bf22..f6e3879 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2837,10 +2837,13 @@ static int fit_segment(Segment *s, Segment *fixed, int *cnt, int dir)
static void
fix_collisions(ASS_Renderer *render_priv, EventImages *imgs, int cnt)
{
- Segment *used = malloc(cnt * sizeof(*used));
+ Segment *used = ass_realloc_array(NULL, cnt, sizeof(*used));
int cnt_used = 0;
int i, j;
+ if (!used)
+ return;
+
// fill used[] with fixed events
for (i = 0; i < cnt; ++i) {
ASS_RenderPriv *priv;