Add safety guard when destroying the mapping

This commit is contained in:
Arnaud 2026-06-01 15:20:23 +04:00
parent 9867ec4787
commit 4532517ca5
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA

View File

@ -266,6 +266,10 @@ proc createMapping*(
proc destroyMapping*(id: cint) {.raises: [].} =
## Must be called exactly once after a successful createMapping.
## Safe to call again or on an unknown id
withSafeLock:
if id notin activeMappings:
return
discard plum_destroy_mapping(id)
proc hasMapping*(id: cint): bool {.raises: [].} =