fix(mobile): buffer width/height referenced after recycling (#26415)

recycle after getters
This commit is contained in:
Mert 2026-02-21 10:41:44 -05:00 committed by GitHub
parent a4d95b7aba
commit 1d25267f22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,7 +48,6 @@ fun Bitmap.toNativeBuffer(): Map<String, Long> {
try {
val buffer = NativeBuffer.wrap(pointer, size)
copyPixelsToBuffer(buffer)
recycle()
return mapOf(
"pointer" to pointer,
"width" to width.toLong(),
@ -57,8 +56,9 @@ fun Bitmap.toNativeBuffer(): Map<String, Long> {
)
} catch (e: Exception) {
NativeBuffer.free(pointer)
recycle()
throw e
} finally {
recycle()
}
}