diff options
author | Vladimir Marko <vmarko@google.com> | 2015-01-07 10:30:44 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-07 10:30:44 +0000 |
commit | 4e2986940b2ff456693a805026c6910e950c42e2 (patch) | |
tree | 5a5ece4844d02e6a750f0dd603f1927d6a029aa7 /core/jni/android | |
parent | 2458f2b12b5ec266538b2019b0f14fca4e772bdf (diff) | |
parent | bf31cb6be4290ce161d99a2a70c318f665a14a77 (diff) | |
download | frameworks_base-4e2986940b2ff456693a805026c6910e950c42e2.zip frameworks_base-4e2986940b2ff456693a805026c6910e950c42e2.tar.gz frameworks_base-4e2986940b2ff456693a805026c6910e950c42e2.tar.bz2 |
am bf31cb6b: am 8371f2e3: Merge "Check for OOM in BitmapFactory\'s getMimeTypeString()."
* commit 'bf31cb6be4290ce161d99a2a70c318f665a14a77':
Check for OOM in BitmapFactory's getMimeTypeString().
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/BitmapFactory.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 099f1b0..e346fc3 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -63,7 +63,7 @@ jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format) { { SkImageDecoder::kWBMP_Format, "image/vnd.wap.wbmp" } }; - const char* cstr = NULL; + const char* cstr = nullptr; for (size_t i = 0; i < SK_ARRAY_COUNT(gMimeTypes); i++) { if (gMimeTypes[i].fFormat == format) { cstr = gMimeTypes[i].fMimeType; @@ -71,8 +71,10 @@ jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format) { } } - jstring jstr = 0; - if (NULL != cstr) { + jstring jstr = nullptr; + if (cstr != nullptr) { + // NOTE: Caller should env->ExceptionCheck() for OOM + // (can't check for nullptr as it's a valid return value) jstr = env->NewStringUTF(cstr); } return jstr; @@ -324,10 +326,13 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding // update options (if any) if (options != NULL) { + jstring mimeType = getMimeTypeString(env, decoder->getFormat()); + if (env->ExceptionCheck()) { + return nullObjectReturn("OOM in getMimeTypeString()"); + } env->SetIntField(options, gOptions_widthFieldID, scaledWidth); env->SetIntField(options, gOptions_heightFieldID, scaledHeight); - env->SetObjectField(options, gOptions_mimeFieldID, - getMimeTypeString(env, decoder->getFormat())); + env->SetObjectField(options, gOptions_mimeFieldID, mimeType); } // if we're in justBounds mode, return now (skip the java bitmap) |