mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix memory leak in GetFileName (#19420)
This commit is contained in:
parent
a428f20d46
commit
3e713e5c2f
|
@ -16,6 +16,7 @@
|
|||
|
||||
# include <SDL.h>
|
||||
# include <jni.h>
|
||||
# include <string>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
|
@ -76,11 +77,7 @@ public:
|
|||
jstring jniString = (jstring)env->CallObjectMethod(_zip, fileNameMethod, (jint)index);
|
||||
|
||||
const char* jniChars = env->GetStringUTFChars(jniString, nullptr);
|
||||
|
||||
utf8* string = (char*)malloc(strlen(jniChars) + 1);
|
||||
std::memcpy((void*)string, jniChars, strlen(jniChars));
|
||||
string[strlen(jniChars)] = 0x00;
|
||||
|
||||
std::string string = jniChars;
|
||||
env->ReleaseStringUTFChars(jniString, jniChars);
|
||||
|
||||
return string;
|
||||
|
|
Loading…
Reference in New Issue