mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 00:34:46 +01:00
Fix memory leak in GetFileName (#19420)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user