Fix crash if pixels are null.

This commit is contained in:
Cody Henthorne 2023-09-24 20:57:24 -04:00
parent d3b0559b72
commit cc6c724ee8

View file

@ -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);