This commit is contained in:
Thibault Deckers 2023-06-24 00:49:20 +02:00
parent 00e030b475
commit fe69c0eba5

View file

@ -205,7 +205,12 @@ class ImageByteStreamHandler(private val context: Context, private val arguments
var len: Int
while (inputStream.read(buffer).also { len = it } != -1) {
// cannot decode image on Flutter side when using `buffer` directly
success(buffer.copyOf(len))
if (MemoryUtils.canAllocate(len)) {
success(buffer.copyOf(len))
} else {
error("streamBytes-memory", "not enough memory to allocate $len bytes", null)
return
}
}
}