]> granicus.if.org Git - libjpeg-turbo/commitdiff
Fix array size calculations
authorDRC <dcommander@users.sourceforge.net>
Thu, 7 Jun 2012 09:38:57 +0000 (09:38 +0000)
committerDRC <dcommander@users.sourceforge.net>
Thu, 7 Jun 2012 09:38:57 +0000 (09:38 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@833 632fc199-4ca6-4c93-a231-07263d6284db

turbojpeg-jni.c

index 3b9624a1ee957090b716f13317bd8dd522c9bd2b..c98845bd2469c81df16137d90321f734ba3f5ccd 100644 (file)
@@ -368,7 +368,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
        if((*env)->GetArrayLength(env, src)<jpegSize)
                _throw("Source buffer is not large enough");
        actualPitch=(pitch==0)? width*tjPixelSize[pf]:pitch;
-       arraySize=(y+height)*actualPitch + x*tjPixelSize[pf];
+       arraySize=(y+height-1)*actualPitch + (x+width)*tjPixelSize[pf];
        if((*env)->GetArrayLength(env, dst)<arraySize)
                _throw("Destination buffer is not large enough");
 
@@ -419,7 +419,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
        if((*env)->GetArrayLength(env, src)<jpegSize)
                _throw("Source buffer is not large enough");
        actualStride=(stride==0)? width:stride;
-       arraySize=(y+height)*actualStride + x;
+       arraySize=(y+height-1)*actualStride + x+width;
        if((*env)->GetArrayLength(env, dst)<arraySize)
                _throw("Destination buffer is not large enough");