From f78cc0d3f92302dd82e46b472f9261613e959390 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 4 Jun 2026 17:00:16 +0200 Subject: [PATCH] PINK: fix last c_char_p temporary in set_slot_json Completes the ctypes lifetime audit. All eight FFI call sites now assign _to_rust_bytes() to a local var before passing to c_char_p, ensuring the bytes object lives for the full duration of the Rust call. Co-Authored-By: Claude Sonnet 4.6 --- prod/clean_arch/dita_v2/rust_backend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prod/clean_arch/dita_v2/rust_backend.py b/prod/clean_arch/dita_v2/rust_backend.py index 4985e98..401febf 100644 --- a/prod/clean_arch/dita_v2/rust_backend.py +++ b/prod/clean_arch/dita_v2/rust_backend.py @@ -219,7 +219,8 @@ class _RustKernelLib: return json.loads(self._take_string(raw)) def set_slot_json(self, handle: ctypes.c_void_p, slot_id: int, payload: Dict[str, Any]) -> None: - rc = self.lib.dita_kernel_set_slot_json(handle, ctypes.c_size_t(slot_id), ctypes.c_char_p(_to_rust_bytes(payload))) + _pb = _to_rust_bytes(payload) + rc = self.lib.dita_kernel_set_slot_json(handle, ctypes.c_size_t(slot_id), ctypes.c_char_p(_pb)) if rc != 0: raise RuntimeError(f"dita_kernel_set_slot_json failed rc={rc}")