From d48c5e749d46a54738f47d2f29deecb66f54b211 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 1 Aug 2023 18:33:28 +0300 Subject: [PATCH 7/7] fill_terrain_sprite_array(): Fix garbage value use See osdn #48456 Signed-off-by: Marko Lindqvist --- client/tilespec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/tilespec.c b/client/tilespec.c index 6e76a47e7a..81a01dcc5e 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -5247,7 +5247,7 @@ static int fill_fog_sprite_array(const struct tileset *t, } /************************************************************************//** - Helper function for fill_terrain_sprite_layer. + Helper function for fill_terrain_sprite_layer(). ****************************************************************************/ static int fill_terrain_sprite_array(struct tileset *t, struct drawn_sprite *sprs, @@ -5362,14 +5362,14 @@ static int fill_terrain_sprite_array(struct tileset *t, break; case MATCH_FULL: default: - { + if (count > 0) { int n[3]; - int j = 0; + int j; - for (; j < 3; j++) { - int k = 0; + for (j = 0; j < 3; j++) { + int k; - for (; k < count; k++) { + for (k = 0; k < count; k++) { n[j] = k; /* Default to last entry */ if (m[j] == dlp->match_index[k]) { break; @@ -5382,6 +5382,7 @@ static int fill_terrain_sprite_array(struct tileset *t, } break; }; + array_index = array_index * NUM_CORNER_DIRS + i; s = dlp->cells[array_index]; -- 2.40.1