commit f4cd8b85ce8e6c354cad90fb12b82eed53321bf8
parent cbe3536070e5a0477cefbca871d93db8bc97dd49
Author: Marc Stibane <marc@taler.net>
Date: Fri, 14 Aug 2026 17:44:53 +0200
AI: withExtendedLifetime
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/TalerWallet1/Quickjs/QuickDataTask.swift b/TalerWallet1/Quickjs/QuickDataTask.swift
@@ -235,7 +235,12 @@ final class QuickDataTask: NSObject, @unchecked Sendable {
body_len: numericCast(data.count)
)
withUnsafeMutablePointer(to: &responseInfo) { responseInfoPtr in
- responseCb(responseCbCls, responseInfoPtr)
+ // cHeaders owns the C strings that response_headers points to, and ARC
+ // only keeps it alive up to its last use - which is reading .pointer
+ // above, before the callback that dereferences it has run
+ withExtendedLifetime(cHeaders) {
+ responseCb(responseCbCls, responseInfoPtr)
+ }
}
}
}