am 8cd48574: Fixed bug in BitmapFactory.decodeStream

Merge commit '8cd48574a755bea86243e9f9eabaee341ecf9c60' into gingerbread-plus-aosp

* commit '8cd48574a755bea86243e9f9eabaee341ecf9c60':
  Fixed bug in BitmapFactory.decodeStream
This commit is contained in:
Gilles Debunne
2010-07-26 11:41:46 -07:00
committed by Android Git Automerger

View File

@@ -52,7 +52,7 @@ public:
return 0; return 0;
} }
if (n <= 0) { if (n < 0) { // n == 0 should not be possible, see InputStream read() specifications.
break; // eof break; // eof
} }
@@ -76,17 +76,19 @@ public:
size_t doSkip(size_t size) { size_t doSkip(size_t size) {
JNIEnv* env = fEnv; JNIEnv* env = fEnv;
jlong skipped = env->CallLongMethod(fJavaInputStream, jlong skipped = env->CallLongMethod(fJavaInputStream,
gInputStream_skipMethodID, (jlong)size); gInputStream_skipMethodID, (jlong)size);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
env->ExceptionDescribe(); env->ExceptionDescribe();
env->ExceptionClear(); env->ExceptionClear();
SkDebugf("------- available threw an exception\n"); SkDebugf("------- skip threw an exception\n");
return 0; return 0;
} }
if (skipped < 0) { if (skipped < 0) {
skipped = 0; skipped = 0;
} }
return (size_t)skipped; return (size_t)skipped;
} }
@@ -115,7 +117,7 @@ public:
*/ */
size_t amountSkipped = 0; size_t amountSkipped = 0;
do { do {
size_t amount = this->doSkip(size); size_t amount = this->doSkip(size - amountSkipped);
if (0 == amount) { if (0 == amount) {
char tmp; char tmp;
amount = this->doRead(&tmp, 1); amount = this->doRead(&tmp, 1);