diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-12-22 10:30:43 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-04-23 23:23:46 +0200 |
commit | 74ebc70886e71aa21b5f32f047a2436117dc89b5 (patch) | |
tree | 9e89f0cf05305018c4c0c5b7a65dcb28db25ed4a | |
parent | e1bac1db5a1834774efdb0229de37ad8675cc632 (diff) | |
download | gnutls-74ebc70886e71aa21b5f32f047a2436117dc89b5.tar.gz |
guile: Avoid potentially missed reference.
There's one case where 'register_weak_reference' is called several times
on the same object, in 'set-certificate-credentials-x509-keys!', where
PRIVKEY could have been GC'd before CRED.
* guile/src/core.c (register_weak_reference): Add TO to the weak
references of FROM instead of overriding them.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r-- | guile/src/core.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/guile/src/core.c b/guile/src/core.c index f61f4c47a2..84e1009bee 100644 --- a/guile/src/core.c +++ b/guile/src/core.c @@ -1,5 +1,5 @@ /* GnuTLS --- Guile bindings for GnuTLS. - Copyright (C) 2007-2014, 2016, 2019 Free Software Foundation, Inc. + Copyright (C) 2007-2014, 2016, 2019, 2020 Free Software Foundation, Inc. GnuTLS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -96,11 +96,13 @@ const char scm_gnutls_array_error_message[] = static SCM weak_refs; /* Register a weak reference from @FROM to @TO, such that the lifetime of TO is - greater than or equal to that of FROM. */ + greater than or equal to that of FROM. TO is added to the list of weak + references of FROM. */ static void register_weak_reference (SCM from, SCM to) { - scm_hashq_set_x (weak_refs, from, to); + SCM refs = scm_cons (to, scm_hashq_ref (weak_refs, from, SCM_EOL)); + scm_hashq_set_x (weak_refs, from, refs); } |