[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] bugfix: add per-key scheme functions to GC roots
From: |
Jason Miller |
Subject: |
[PATCH] bugfix: add per-key scheme functions to GC roots |
Date: |
Fri, 22 May 2020 17:30:05 -0700 |
Prior to this change, the scheme functions could be garbage collected.
This would eventually cause crashes if any of the scheme functions in
the user's configuration allocate memory.
---
keys.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/keys.c b/keys.c
index a1928f5..f90096c 100644
--- a/keys.c
+++ b/keys.c
@@ -105,6 +105,9 @@ add_key (KeyType_t type, EventType_t event_type, KeySym
keysym, KeyCode keycode,
modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);
+#ifdef GUILE_FLAG
+ if(function) scm_gc_protect_object(function);
+#endif
/* set key */
if (type == SYM)
{
@@ -344,6 +347,9 @@ free_key (Keys_t * key)
if (key->command != NULL)
free (key->command);
+#ifdef GUILE_FLAG
+ if(key->function) scm_gc_unprotect_object(key->function);
+#endif
key->function = 0;
}
--
2.25.4
- [PATCH] bugfix: add per-key scheme functions to GC roots,
Jason Miller <=