summaryrefslogtreecommitdiff
path: root/src/gnutls.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-01-17 17:16:12 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-01-17 17:17:01 -0800
commit130d512045aa376333b664d58c501b3884187592 (patch)
treefe7b2fa10229b204eeb16aa34d0191864caf9e70 /src/gnutls.c
parent0f3ea5e172e584875fa5808322af8a7c75503f7b (diff)
Initialize GnuTLS before calling gnutls_rnd
* src/gnutls.c (emacs_gnutls_global_init): Now extern. Don’t set gnutls_global_initialized if gnutls_global_init fails. * src/sysdep.c: Include "gnutls.h", and <gnutls/crypto.h> if 2.12 or later, which has gnutls_rnd. (emacs_gnutls_global_init, gnutls_rnd): New fallback placeholder macros if before 2.12. (init_random): Initialize gnutls globals before trying to use gnutls_rnd.
Diffstat (limited to 'src/gnutls.c')
-rw-r--r--src/gnutls.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index a1d058fcd4..01a5983d3b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1112,15 +1112,17 @@ The return value is a property list with top-level keys :warnings and
/* Initialize global GnuTLS state to defaults.
Call `gnutls-global-deinit' when GnuTLS usage is no longer needed.
Return zero on success. */
-static Lisp_Object
+Lisp_Object
emacs_gnutls_global_init (void)
{
int ret = GNUTLS_E_SUCCESS;
if (!gnutls_global_initialized)
- ret = gnutls_global_init ();
-
- gnutls_global_initialized = 1;
+ {
+ ret = gnutls_global_init ();
+ if (ret == GNUTLS_E_SUCCESS)
+ gnutls_global_initialized = 1;
+ }
return gnutls_make_error (ret);
}