From 1b2795913a99e5df799b272528dcf57e8d6fce3f Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 17 Nov 2014 21:24:52 +0100 Subject: 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. --- libass/ass_render.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libass/ass_render.c') 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; -- cgit v1.2.3