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

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes Android_JNI_FileRead behaviour where reading past the end of a …
…file returns zero instead of the number of bytes read.
  • Loading branch information
gabomdq committed Jul 20, 2012
1 parent 28b3ffe commit 46b3060
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/android/SDL_android.cpp
Expand Up @@ -591,9 +591,13 @@ extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
size_t size, size_t maxnum)
{
LocalReferenceHolder refs;
int bytesRemaining = size * maxnum;
jlong bytesRemaining = (jlong) (size * maxnum);
jlong bytesMax = (jlong) (ctx->hidden.androidio.size - ctx->hidden.androidio.position);
int bytesRead = 0;

/* Don't read more bytes than those that remain in the file, otherwise we get an exception */
if (bytesRemaining > bytesMax) bytesRemaining = bytesMax;

JNIEnv *mEnv = Android_JNI_GetEnv();
if (!refs.init(mEnv)) {
return -1;
Expand Down

0 comments on commit 46b3060

Please sign in to comment.