Skip to content

Commit 1b80a50

Browse files
committed
NPE when getting stableref?
1 parent 890e2fb commit 1b80a50

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

aws-crt-kotlin/native/src/aws/sdk/kotlin/crt/http/HttpClientConnectionNative.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ private fun onIncomingBody(
142142
data: CPointer<aws_byte_cursor>?,
143143
userdata: COpaquePointer?,
144144
): Int {
145-
val stableRef = userdata?.asStableRef<HttpStreamContext>()
146-
val ctx = stableRef?.get()
145+
val stableRef = try { userdata?.asStableRef<HttpStreamContext>() } catch (_: NullPointerException) { return AWS_OP_ERR }
146+
val ctx = try { stableRef?.get() } catch (_: NullPointerException) { return AWS_OP_ERR }
147147
if (ctx == null) return AWS_OP_ERR
148148
val stream = ctx.stream
149149
if (stream == null) return AWS_OP_ERR

0 commit comments

Comments
 (0)