]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: (Hopefully) safer bitmap creation
authorKarryanna <karry@karryanna.cz>
Wed, 13 May 2015 09:41:41 +0000 (11:41 +0200)
committerKarryanna <karry@karryanna.cz>
Wed, 13 May 2015 09:41:41 +0000 (11:41 +0200)
labeller.c

index 7465f86cefb976c07965542a757e77f86cbb6c92..7e0ea427503d381de8a6743f374fd2c5635e4939 100644 (file)
@@ -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; i<v->width*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; i<sp->size*sp->size; i++) v->bitmap[i] = 1;
 }