From d0a989bea06221282e1bde556d160edebe9d9bf7 Mon Sep 17 00:00:00 2001 From: Maarten Hoeben <> Date: Sat, 18 Jul 2026 09:08:30 +0100 Subject: [PATCH] Fixed bug #33 by moving the definition of tiles and base_tile_cnt before possible early jumps to the CLEANUP label. --- wfc.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wfc.h b/wfc.h index 0ed5e5f..a1679db 100644 --- a/wfc.h +++ b/wfc.h @@ -1314,6 +1314,9 @@ static struct wfc__tile *wfc__create_tiles_overlapping(struct wfc_image *image, int xcnt = image->width - tile_width + 1; int ycnt = image->height - tile_height + 1; + struct wfc__tile *tiles = NULL; + int base_tile_cnt = 0; + if (expand_image) { xcnt = image->width; ycnt = image->height; @@ -1331,7 +1334,7 @@ static struct wfc__tile *wfc__create_tiles_overlapping(struct wfc_image *image, if (rotate_tiles) *tile_cnt *= 4; - struct wfc__tile *tiles = wfc__create_tiles(*tile_cnt); + tiles = wfc__create_tiles(*tile_cnt); if (tiles == NULL) goto CLEANUP; @@ -1339,7 +1342,7 @@ static struct wfc__tile *wfc__create_tiles_overlapping(struct wfc_image *image, if (!wfc__add_overlapping_images(tiles, image, xcnt, ycnt, tile_width, tile_height)) goto CLEANUP; - int base_tile_cnt = xcnt * ycnt; + base_tile_cnt = xcnt * ycnt; if (xflip_tiles) { if (!wfc__add_flipped_images(tiles, base_tile_cnt, 0)) goto CLEANUP;