diff options
author | wm4 <wm4@nowhere> | 2014-11-17 21:24:52 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-17 21:24:52 +0100 |
commit | 1b2795913a99e5df799b272528dcf57e8d6fce3f (patch) | |
tree | a990abb094d346ecab018a01aa3e2476db41c917 /libass/ass_render.c | |
parent | 2f9467cfd2574af44f97ee89b460c410a5a3c85a (diff) | |
download | libass-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index b88bf222..f6e38797 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; |