all repos — mgba @ 2594015853b4a3fb276dec5dd80f4ccc5d2bc566

mGBA Game Boy Advance Emulator

Util: Fix resource leak in UTF-8 handling code
Jeffrey Pfau jeffrey@endrift.com
Wed, 22 Apr 2015 22:02:55 -0700
commit

2594015853b4a3fb276dec5dd80f4ccc5d2bc566

parent

8aa9c4503a28a89541d891140bfff7218bc2701a

2 files changed, 3 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -19,6 +19,7 @@ - Qt: Fix multiplayer windows opening as the wrong size

- Qt: Fix controllers sometimes not loading the right profile - GBA: Fix hang when loading a savestate if sync to video is enabled - Debugger: Fix use-after-free in breakpoint clearing code + - Util: Fix resource leak in UTF-8 handling code Misc: - Qt: Show multiplayer numbers in window title - Qt: Solar sensor can have shortcuts set
M src/util/string.csrc/util/string.c

@@ -178,13 +178,14 @@ memcpy(utf8, buffer, bytes);

offset = utf8 + bytes; } else if (utf8Length >= utf8TotalBytes) { char* newUTF8 = realloc(utf8, utf8TotalBytes * 2); + offset = offset - utf8 + newUTF8; if (newUTF8 != utf8) { free(utf8); } if (!newUTF8) { return 0; } - offset = offset - utf8 + newUTF8; + utf8 = newUTF8; memcpy(offset, buffer, bytes); offset += bytes; }