mirror of https://github.com/mgba-emu/mgba.git
Util: Fix resource leak in UTF-8 handling code
This commit is contained in:
parent
c4aedfa69a
commit
9552512329
1
CHANGES
1
CHANGES
|
@ -35,6 +35,7 @@ Bugfixes:
|
|||
- 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: Handle saving input settings better
|
||||
|
|
|
@ -178,13 +178,14 @@ char* utf16to8(const uint16_t* utf16, size_t length) {
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue