From: Karryanna Date: Wed, 13 May 2015 09:41:41 +0000 (+0200) Subject: Labelling: (Hopefully) safer bitmap creation X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=60f15efca7ec57ed925781546f6a0074cfa210e1;p=leo.git Labelling: (Hopefully) safer bitmap creation --- 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; }