From 4532517ca5b29172e6d624f5fc62bc6a9c6f3a4a Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 1 Jun 2026 15:20:23 +0400 Subject: [PATCH] Add safety guard when destroying the mapping --- libplum/plum.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libplum/plum.nim b/libplum/plum.nim index c70fd33..9201756 100644 --- a/libplum/plum.nim +++ b/libplum/plum.nim @@ -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: [].} =