Bug#981447: hex-a-hop: Memory leak in savestate.h

Davide Prina Davide.Prina at gmail.com
Sun Jan 31 13:05:33 GMT 2021


Package: hex-a-hop
Version: 1.1.0+git20140926-1.1
Severity: minor
Tags: patch
X-Debbugs-Cc: Davide.Prina at gmail.com

Using valgrind I see:

$ valgrind --leak-check=full --num-callers=50 --show-reachable=no --show-possibly-lost=no --track-origins=yes --trace-children=yes --read-var-info=yes hex-a-hop

==17701== 1,151 bytes in 100 blocks are definitely lost in loss record 688 of 762
==17701==    at 0x483950F: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==17701==    by 0x113AC1: SetSolution (savestate.h:141)
==17701==    by 0x113AC1: LoadSave (savestate.h:84)
==17701==    by 0x113AC1: SaveState::LoadSave(_IO_FILE*, bool) (savestate.h:281)
==17701==    by 0x115357: TitleMenu::TitleMenu() (menus.h:986)
==17701==    by 0x11A030: HexPuzzle::ResetLevel() (hex_puzzzle.cpp:1635)
==17701==    by 0x11A4F1: HexPuzzle::_LoadSave(_IO_FILE*, bool) (hex_puzzzle.cpp:2045)
==17701==    by 0x11AD31: HexPuzzle::LoadSave(char const*, bool) (hex_puzzzle.cpp:1830)
==17701==    by 0x11DDDD: LoadMap (hex_puzzzle.cpp:2453)
==17701==    by 0x11DDDD: LoadMap (hex_puzzzle.cpp:2447)
==17701==    by 0x11DDDD: HexPuzzle::HexPuzzle() (hex_puzzzle.cpp:2444)
==17701==    by 0x11E19F: StateMaker<HexPuzzle>::Create() (state.h:216)
==17701==    by 0x10ECAB: GetNew (state.h:198)
==17701==    by 0x10ECAB: main (gfx.cpp:273)

Note: I start the game and then exit

as you can see the last bestSolution allocation is never free.
I have added a destructor to the class for free the memory.

Ciao
Davide

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'testing-debug'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.9-dp-20210128 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=it_IT.utf8, LC_CTYPE=it_IT.utf8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages hex-a-hop depends on:
ii  hex-a-hop-data   1.1.0+git20140926-1.1
ii  libc6            2.31-9
ii  libgcc-s1        10.2.1-6
ii  libsdl-image1.2  1.2.12-12
ii  libsdl-mixer1.2  1.2.12-16+b1
ii  libsdl-pango1    0.1.2-8+b1
ii  libsdl1.2debian  1.2.15+dfsg2-5
ii  libstdc++6       10.2.1-6

hex-a-hop recommends no packages.

hex-a-hop suggests no packages.

-- no debconf information
-------------- next part --------------
--- savestate.h.orig	2021-01-31 13:58:40.779526699 +0100
+++ savestate.h	2021-01-31 13:16:49.239638855 +0100
@@ -48,6 +48,10 @@
 	{
 		Clear();
 	}
+	~LevelSave()
+	{
+		delete [] bestSolution;
+	}
 	void Clear()
 	{
 		unlocked = 0;


More information about the Pkg-games-devel mailing list