From 6fd2169541269021f4b6d2dd09809f0ced7dc5a3 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 3 May 2026 13:41:25 +0300 Subject: Fix some memory leaks --- map.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/map.c b/map.c index a5e528c..03e69f5 100644 --- a/map.c +++ b/map.c @@ -819,7 +819,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi if (row < *height && col < *width && (*map)[row][col] != WALL && (col != goal->x || row != goal->y)) { start->x = col; start->y = row; - if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + if (should_pathfind) { + path_free(path, *height); + path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + } draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL); } } @@ -830,7 +833,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi if (row < *height && col < *width && (*map)[row][col] != WALL && (col != start->x || row != start->y)) { goal->x = col; goal->y = row; - if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + if (should_pathfind) { + path_free(path, *height); + path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + } draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL); } } -- cgit v1.2.3