Fixes potential global reference leak on Android, by Philipp Wiesemann
This commit is contained in:
parent
02db40b1b2
commit
9e1dc0a80d
1 changed files with 1 additions and 2 deletions
|
@ -593,7 +593,6 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
|
|||
goto fallback;
|
||||
}
|
||||
|
||||
ctx->hidden.androidio.assetFileDescriptorRef = mEnv->NewGlobalRef(inputStream);
|
||||
mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream), "getStartOffset", "()J");
|
||||
ctx->hidden.androidio.offset = mEnv->CallLongMethod(inputStream, mid);
|
||||
if (Android_JNI_ExceptionOccurred()) {
|
||||
|
@ -602,7 +601,6 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
|
|||
|
||||
mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream), "getDeclaredLength", "()J");
|
||||
ctx->hidden.androidio.size = mEnv->CallLongMethod(inputStream, mid);
|
||||
|
||||
if (Android_JNI_ExceptionOccurred()) {
|
||||
goto fallback;
|
||||
}
|
||||
|
@ -612,6 +610,7 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
|
|||
fdCls = mEnv->GetObjectClass(fd);
|
||||
descriptor = mEnv->GetFieldID(fdCls, "descriptor", "I");
|
||||
ctx->hidden.androidio.fd = mEnv->GetIntField(fd, descriptor);
|
||||
ctx->hidden.androidio.assetFileDescriptorRef = mEnv->NewGlobalRef(inputStream);
|
||||
|
||||
// Seek to the correct offset in the file.
|
||||
lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue