From 124ea99dec38b5b1a591638484dc2e708bcb482a Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Fri, 5 Sep 2025 16:38:02 +0200 Subject: [PATCH] Guard image decode with catch(Throwable) to prevent OOM crashes Wrap the entire decodeToBitmap() body in a try/catch that handles Throwable. This ensures both Exception and OutOfMemoryError are caught, preventing the app from crashing on oversized or invalid image inputs. Instead, an empty IntArray is returned to JNI callers. --- .../src/main/java/app/rive/runtime/kotlin/core/ImageDecoder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin/src/main/java/app/rive/runtime/kotlin/core/ImageDecoder.kt b/kotlin/src/main/java/app/rive/runtime/kotlin/core/ImageDecoder.kt index d79826c9..9ef04d5b 100644 --- a/kotlin/src/main/java/app/rive/runtime/kotlin/core/ImageDecoder.kt +++ b/kotlin/src/main/java/app/rive/runtime/kotlin/core/ImageDecoder.kt @@ -27,7 +27,7 @@ object ImageDecoder { pixels[1] = height bitmap.getPixels(pixels, offset, width, 0, 0, width, height) pixels - } catch (e: Exception) { + } catch (t: Throwable) { IntArray(0) } }