From 8eb3b3d8d108dece5d2e35caa54e3030418b8b7d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 7 Jan 2023 13:20:39 +0200 Subject: [PATCH] Silence valgrind uninitialized bytes complaints Just zero out the allocated memory. Explicitly setting struct field values isn't enough, because field alignment means there can be several unused bytes which are written to savefile. --- src/dungeon.c | 1 + src/mklev.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/dungeon.c b/src/dungeon.c index 1f0c56519..07cd2f56b 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1484,6 +1484,7 @@ stairway_add(coordxy x, coordxy y, boolean up, boolean isladder, d_level *dest) { stairway *tmp = (stairway *) alloc(sizeof (stairway)); + (void) memset((genericptr_t) tmp, 0, sizeof (stairway)); tmp->sx = x; tmp->sy = y; tmp->up = up; diff --git a/src/mklev.c b/src/mklev.c index 388591db7..3de0635e4 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -458,6 +458,8 @@ alloc_doors(void) if (!gd.doors || gd.doorindex >= gd.doors_alloc) { int c = gd.doors_alloc + DOORINC; coord *doortmp = (coord *) alloc(c * sizeof(coord)); + + (void) memset((genericptr_t) doortmp, 0, c * sizeof(coord)); if (gd.doors) { (void) memcpy(doortmp, gd.doors, gd.doors_alloc * sizeof(coord)); free(gd.doors);