From 60f15efca7ec57ed925781546f6a0074cfa210e1 Mon Sep 17 00:00:00 2001 From: Karryanna Date: Wed, 13 May 2015 11:41:41 +0200 Subject: [PATCH] Labelling: (Hopefully) safer bitmap creation --- labeller.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/labeller.c b/labeller.c index 7465f86..7e0ea42 100644 --- a/labeller.c +++ b/labeller.c @@ -251,16 +251,16 @@ void make_bitmap(struct variant *v, struct symbol *sym) void make_bitmap_icon(struct variant *v, struct sym_icon *si) { - v->width = si->sir.icon->width; - v->height = si->sir.icon->height; - v->bitmap = malloc((int) ceil(v->width * v->height * sizeof(bool))); + v->width = si->sir.width + 1; + v->height = si->sir.height + 1; + v->bitmap = malloc(v->width * v->height * sizeof(bool)); for (int i=0; iwidth*v->height; i++) v->bitmap[i] = 1; } void make_bitmap_point(struct variant *v, struct sym_point *sp) { - v->width = v->height = sp->size; - v->bitmap = malloc(sp->size*sp->size * sizeof(bool)); + v->width = v->height = sp->size + 1; + v->bitmap = malloc(v->width * v->height * sizeof(bool)); // FIXME: Okay, memset would be much nicer here for (int i=0; isize*sp->size; i++) v->bitmap[i] = 1; } -- 2.39.2