Found a bug in R'n'D? Report it here!
Moderators: Flumminator , Zomis
filbo
Posts: 677 Joined: Fri Jun 20, 2014 10:06 am
Post
by filbo » Thu Apr 18, 2019 10:13 pm
Code: Select all
$ make sdl2 RO_GAME_DIR=/usr/share/games/rocksndiamonds RW_GAME_DIR=/var/games/rocksndiamonds
$ ./rocksndiamonds
*** Error in `./rocksndiamonds': free(): invalid pointer: 0x0000000000592d38 ***
Aborted
-- because getProgramMainDataPath() returns RO_BASE_PATH, which is a constant and can't be free()'d in line 521 `checked_free(ro_base_path);'
Code: Select all
$ git diff -U1
diff --git a/src/libgame/setup.c b/src/libgame/setup.c
index 7e87a76..5cdaa87 100644
--- a/src/libgame/setup.c
+++ b/src/libgame/setup.c
@@ -459,3 +459,3 @@ char *getProgramMainDataPath(char *command_filename, char *base_path)
if (!strEqual(base_path, "."))
- return base_path;
+ return getStringCopy(base_path);
Holger
Site Admin
Posts: 4278 Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:
Post
by Holger » Thu Apr 18, 2019 11:08 pm
Yeah, right -- this (a function than may return a string constant or string copy) was always wrong, but did not cause much harm as long as the result was never properly free()'d.
Fixed using your patch! Thanks!