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 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-06-04 17:00:16 +02:00
parent acffc783e6
commit f78cc0d3f9

View File

@@ -219,7 +219,8 @@ class _RustKernelLib:
return json.loads(self._take_string(raw)) 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: 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: if rc != 0:
raise RuntimeError(f"dita_kernel_set_slot_json failed rc={rc}") raise RuntimeError(f"dita_kernel_set_slot_json failed rc={rc}")