Unverified Commit 549de5ab authored by Aleksandr Veselov's avatar Aleksandr Veselov Committed by GitHub

Add zero terminator to native interop strings (#333)

parent 1a0c1c53
......@@ -58,7 +58,9 @@ actual class InteropScope actual constructor() {
actual fun toInterop(string: String?): InteropPointer {
return if (string != null) {
// encodeToByteArray encodes to utf8
val pinned = string.encodeToByteArray().pin()
val utf8 = string.encodeToByteArray()
// TODO Remove array copy, use `skString(data, length)` instead of `skString(data)`
val pinned = utf8.copyOf(utf8.size + 1).pin()
elements.add(pinned)
val result = pinned.addressOf(0).rawValue
result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment