From cc6c724ee8427c8c69eaa796f8d7cc8a4a804e97 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Sun, 24 Sep 2023 20:57:24 -0400 Subject: [PATCH] Fix crash if pixels are null. --- glide-webp/lib/src/main/cpp/signalwebp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glide-webp/lib/src/main/cpp/signalwebp.cpp b/glide-webp/lib/src/main/cpp/signalwebp.cpp index a2702229a1..a41ef57161 100644 --- a/glide-webp/lib/src/main/cpp/signalwebp.cpp +++ b/glide-webp/lib/src/main/cpp/signalwebp.cpp @@ -29,7 +29,10 @@ jobject nativeDecodeBitmap(JNIEnv *env, jobject, jbyteArray data) { int height; uint8_t *pixels = WebPDecodeBGRA(buffer, bufferLength, &width, &height); - jobject jbitmap = createBitmap(env, width, height, pixels); + jobject jbitmap = nullptr; + if (pixels != nullptr) { + jbitmap = createBitmap(env, width, height, pixels); + } WebPFree(pixels); env->ReleaseByteArrayElements(data, javaBytes, 0);