From 121efcc5618374a1b4450b1d6a18bb3c35edb1fd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 7 Jan 2014 13:32:08 +0100 Subject: Make gpgme_new return a proper error if no engines are installed. * src/engine.c (gpgme_get_engine_info): Improve error handling. (_gpgme_engine_info_copy): Ditto. * src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE. --- src/gpgme.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gpgme.c') diff --git a/src/gpgme.c b/src/gpgme.c index 4a8afa96..3d00018f 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -86,6 +86,7 @@ gpgme_set_global_flag (const char *name, const char *value) gpgme_error_t gpgme_new (gpgme_ctx_t *r_ctx) { + gpgme_error_t err; gpgme_ctx_t ctx; TRACE_BEG (DEBUG_CTX, "gpgme_new", r_ctx); @@ -101,11 +102,13 @@ gpgme_new (gpgme_ctx_t *r_ctx) INIT_LOCK (ctx->lock); - _gpgme_engine_info_copy (&ctx->engine_info); - if (!ctx->engine_info) + err = _gpgme_engine_info_copy (&ctx->engine_info); + if (!err && !ctx->engine_info) + err = gpg_error (GPG_ERR_NO_ENGINE); + if (err) { free (ctx); - return TRACE_ERR (gpg_error_from_syserror ()); + return TRACE_ERR (err); } ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; -- cgit v1.2.3