Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixes potential global reference leak on Android, by Philipp Wiesemann
Browse files Browse the repository at this point in the history
  • Loading branch information
gabomdq committed Jan 28, 2013
1 parent a0454be commit 89bce93
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/android/SDL_android.cpp
Expand Up @@ -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()) {
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit 89bce93

Please sign in to comment.