summaryrefslogtreecommitdiffstats
path: root/libass/ass_bitmap.c
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2014-11-07 14:49:18 -0400
committerRodger Combs <rodger.combs@gmail.com>2014-11-08 10:39:28 -0600
commit0e8772a3bdca491230c90d3c9c7ab2ac5c18c2e7 (patch)
tree9464ee1d05593d4abbeb321d84aa42264d1ad6f0 /libass/ass_bitmap.c
parenta31ea5621a1fca4a4c927d11ece43c36b44b372c (diff)
downloadlibass-0e8772a3bdca491230c90d3c9c7ab2ac5c18c2e7.tar.bz2
libass-0e8772a3bdca491230c90d3c9c7ab2ac5c18c2e7.tar.xz
Check more allocations
Part of #146
Diffstat (limited to 'libass/ass_bitmap.c')
-rw-r--r--libass/ass_bitmap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index 9a98f5a..6de70f0 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -133,7 +133,13 @@ static Bitmap *alloc_bitmap_raw(int w, int h)
unsigned align = (w >= 32) ? 32 : ((w >= 16) ? 16 : 1);
unsigned s = ass_align(align, w);
bm = malloc(sizeof(Bitmap));
+ if (!bm)
+ return NULL;
bm->buffer = ass_aligned_alloc(align, s * h + 32);
+ if (!bm->buffer) {
+ free(bm);
+ return NULL;
+ }
bm->w = w;
bm->h = h;
bm->stride = s;
@@ -160,6 +166,8 @@ void ass_free_bitmap(Bitmap *bm)
Bitmap *copy_bitmap(const Bitmap *src)
{
Bitmap *dst = alloc_bitmap_raw(src->w, src->h);
+ if (!dst)
+ return NULL;
dst->left = src->left;
dst->top = src->top;
memcpy(dst->buffer, src->buffer, src->stride * src->h);
@@ -179,6 +187,8 @@ Bitmap *outline_to_bitmap(ASS_Renderer *render_priv,
if (rst->x_min >= rst->x_max || rst->y_min >= rst->y_max) {
Bitmap *bm = alloc_bitmap(2 * bord, 2 * bord);
+ if (!bm)
+ return NULL;
bm->left = bm->top = -bord;
return bm;
}
@@ -200,6 +210,8 @@ Bitmap *outline_to_bitmap(ASS_Renderer *render_priv,
int tile_w = (w + 2 * bord + mask) & ~mask;
int tile_h = (h + 2 * bord + mask) & ~mask;
Bitmap *bm = alloc_bitmap(tile_w, tile_h);
+ if (!bm)
+ return NULL;
bm->left = x_min - bord;
bm->top = -y_max - bord;
@@ -234,6 +246,8 @@ Bitmap *outline_to_bitmap(ASS_Renderer *render_priv,
FT_Outline_Get_CBox(outline, &bbox);
if (bbox.xMin >= bbox.xMax || bbox.yMin >= bbox.yMax) {
bm = alloc_bitmap(2 * bord, 2 * bord);
+ if (!bm)
+ return NULL;
bm->left = bm->top = -bord;
return bm;
}
@@ -259,6 +273,8 @@ Bitmap *outline_to_bitmap(ASS_Renderer *render_priv,
// allocate and set up bitmap
bm = alloc_bitmap(w + 2 * bord, h + 2 * bord);
+ if (!bm)
+ return NULL;
bm->left = bbox.xMin - bord;
bm->top = -bbox.yMax - bord;
bitmap.width = w;