From 4898eb65e543d66aba554fb7d4f649ec7e06166c Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Fri, 13 Jan 2006 22:56:41 +0000 Subject: [PATCH] (sona): Fix memory allocation for rad[] and vis[]. The space request for rad[] and vis[] is too small because it did not consider the size of the array element. Broken in rev. 1.15. --- src/lib/commands/sona.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/commands/sona.c b/src/lib/commands/sona.c index f3558912..8b3f3011 100644 --- a/src/lib/commands/sona.c +++ b/src/lib/commands/sona.c @@ -86,7 +86,7 @@ sona(void) if (!visbuf) visbuf = malloc((WORLD_Y * (WORLD_X + 1))); if (!rad) { - rad = malloc(WORLD_Y); + rad = malloc(WORLD_Y * sizeof(char *)); if (rad && radbuf) { for (x = 0; x < WORLD_Y; x++) { rad[x] = &radbuf[(WORLD_X + 1) * x]; @@ -97,7 +97,7 @@ sona(void) } } if (!vis) { - vis = malloc(WORLD_Y); + vis = malloc(WORLD_Y * sizeof(char *)); if (vis && visbuf) { for (x = 0; x < WORLD_Y; x++) { vis[x] = &visbuf[(WORLD_X + 1) * x];