Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixes potential global reference leak on Android, by Philipp Wiesemann

  • Loading branch information
gabomdq committed Jan 28, 2013
1 parent a0454be commit 89bce9314bef0f997cc7e534dd9152a9dfdff641
Showing with 1 addition and 2 deletions.
  1. +1 −2 src/core/android/SDL_android.cpp
@@ -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);

0 comments on commit 89bce93

Please sign in to comment.