src/core/android/SDL_android.cpp
changeset 6377 3d868ca4782f
parent 6354 17840f487124
child 6392 fa7eb111f994
     1.1 --- a/src/core/android/SDL_android.cpp	Fri Jul 20 13:52:25 2012 -0400
     1.2 +++ b/src/core/android/SDL_android.cpp	Fri Jul 20 15:22:48 2012 -0300
     1.3 @@ -591,9 +591,13 @@
     1.4          size_t size, size_t maxnum)
     1.5  {
     1.6      LocalReferenceHolder refs;
     1.7 -    int bytesRemaining = size * maxnum;
     1.8 +    jlong bytesRemaining = (jlong) (size * maxnum);
     1.9 +    jlong bytesMax = (jlong) (ctx->hidden.androidio.size -  ctx->hidden.androidio.position);
    1.10      int bytesRead = 0;
    1.11  
    1.12 +    /* Don't read more bytes than those that remain in the file, otherwise we get an exception */
    1.13 +    if (bytesRemaining >  bytesMax) bytesRemaining = bytesMax;
    1.14 +
    1.15      JNIEnv *mEnv = Android_JNI_GetEnv();
    1.16      if (!refs.init(mEnv)) {
    1.17          return -1;