bubble structure contains pointer into static array. Bubble objects

are being flat-dumped into save file and this causes segfault in restore()
whenever data segment layout changes (e.g. global variables added/removed).
bmask should either be stored with the objects.
This commit is contained in:
Alex Kompel
2015-04-26 14:47:38 -07:00
parent 8624709c0d
commit 664b4eb643
2 changed files with 9 additions and 2 deletions

View File

@@ -1267,6 +1267,9 @@ register int x, y, n;
impossible("n too large (mk_bubble)");
n = SIZE(bmask) - 1;
}
if (bmask[n][1] > MAX_BMASK) {
panic("bmask size is larger than MAX_BMASK");
}
b = (struct bubble *)alloc(sizeof(struct bubble));
if ((x + (int) bmask[n][0] - 1) > bxmax) x = bxmax - bmask[n][0] + 1;
if ((y + (int) bmask[n][1] - 1) > bymax) y = bymax - bmask[n][1] + 1;
@@ -1274,7 +1277,9 @@ register int x, y, n;
b->y = y;
b->dx = 1 - rn2(3);
b->dy = 1 - rn2(3);
b->bm = bmask[n];
/* y dimension is the length of bitmap data - see bmask above */
(void)memcpy((genericptr_t)b->bm, (genericptr_t)bmask[n],
(bmask[n][1]+2)*sizeof(b->bm[0]));
b->cons = 0;
if (!bbubbles) bbubbles = b;
if (ebubbles) {