mirror of https://github.com/mgba-emu/mgba.git
Util: Fix realloc semantics in utf16to8 (again)
This commit is contained in:
parent
f4e26656e4
commit
8862dc49aa
|
@ -187,12 +187,11 @@ char* utf16to8(const uint16_t* utf16, size_t length) {
|
|||
memcpy(utf8, buffer, bytes);
|
||||
offset = utf8 + bytes;
|
||||
} else if (utf8Length >= utf8TotalBytes) {
|
||||
ptrdiff_t o = offset - utf8;
|
||||
char* newUTF8 = realloc(utf8, utf8TotalBytes * 2);
|
||||
offset = offset - utf8 + newUTF8;
|
||||
if (newUTF8 != utf8) {
|
||||
free(utf8);
|
||||
}
|
||||
offset = o + newUTF8;
|
||||
if (!newUTF8) {
|
||||
free(utf8);
|
||||
return 0;
|
||||
}
|
||||
utf8 = newUTF8;
|
||||
|
|
Loading…
Reference in New Issue