Fix out of bounds when trying to get a pointer to empty array
This commit is contained in:
3 files changed
+161
-1
No files matched your search
+7
-1
@@ -11,4 +11,10 @@ import kotlinx.cinterop.toCPointer
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 27-Aug-2020
|
||||
*/
|
||||
fun Pinned<UByteArray>.toPtr() : CPointer<UByteVar>? = addressOf(0)
|
||||
fun Pinned<UByteArray>.toPtr() : CPointer<UByteVar>? {
|
||||
return try {
|
||||
addressOf(0)
|
||||
} catch (outOfBounds : ArrayIndexOutOfBoundsException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user