Skip to content

Commit 951bc29

Browse files
committed
Added check for options befor setting to context
1 parent 519e796 commit 951bc29

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

webpgPlugin/webpgPluginAPI.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,18 @@ gpgme_ctx_t webpgPluginAPI::get_gpgme_ctx()
340340
#endif
341341

342342
err = gpgme_new (&ctx);
343-
gpgme_engine_info_t engine_info = gpgme_ctx_get_engine_info (ctx);
344-
err = gpgme_ctx_set_engine_info (ctx, engine_info->protocol,
345-
(GNUPGBIN.length() > 0) ? (char *) GNUPGBIN.c_str() : NULL,
346-
(GNUPGHOME.length() > 0) ? (char *) GNUPGHOME.c_str() : NULL);
343+
if (GNUPGBIN.length() > 0
344+
|| GNUPGHOME.length() > 0) {
345+
gpgme_engine_info_t engine_info = gpgme_ctx_get_engine_info (ctx);
346+
err = gpgme_ctx_set_engine_info (ctx, engine_info->protocol,
347+
(GNUPGBIN.length() > 0) ? (char *) GNUPGBIN.c_str() : NULL,
348+
(GNUPGHOME.length() > 0) ? (char *) GNUPGHOME.c_str() : NULL);
349+
}
347350

348351
// Check the GPGCONF variable, if not null, set the GPGCONF
349352
// engine to use that path
350-
err = gpgme_ctx_set_engine_info (ctx, GPGME_PROTOCOL_GPGCONF,
353+
if (GPGCONF.length() > 0)
354+
err = gpgme_ctx_set_engine_info (ctx, GPGME_PROTOCOL_GPGCONF,
351355
(GPGCONF.length() > 0) ? (char *) GPGCONF.c_str() : NULL, NULL);
352356

353357
gpgme_set_textmode (ctx, 1);

0 commit comments

Comments
 (0)