From 48472e9516cc297894b40d50cf7fce199546e9db Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Wed, 17 Jul 2013 12:54:49 +0000 Subject: [PATCH] error checking and ensure we check version --- gnupg.c | 9 ++++++--- gnupg_keylistiterator.c | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gnupg.c b/gnupg.c index 5ebc9d1..ef13908 100644 --- a/gnupg.c +++ b/gnupg.c @@ -136,12 +136,15 @@ static void gnupg_res_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { static void gnupg_res_init(gnupg_object *intern TSRMLS_DC){ /* init the gpgme-lib and set the default values */ gpgme_ctx_t ctx; + gpgme_error_t err; gpgme_check_version (NULL); - gpgme_new (&ctx); + err = gpgme_new(&ctx); + if(err == GPG_ERR_NO_ERROR) { #ifdef GNUPG_PATH - gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_OpenPGP, GNUPG_PATH, NULL); + gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_OpenPGP, GNUPG_PATH, NULL); #endif - gpgme_set_armor (ctx,1); + gpgme_set_armor (ctx,1); + } intern->ctx = ctx; intern->encryptkeys = NULL; intern->encrypt_size = 0; diff --git a/gnupg_keylistiterator.c b/gnupg_keylistiterator.c index 218b5dd..c1a8a8b 100644 --- a/gnupg_keylistiterator.c +++ b/gnupg_keylistiterator.c @@ -80,6 +80,7 @@ zend_object_value gnupg_keylistiterator_objects_new(zend_class_entry *class_type retval.handle = zend_objects_store_put(intern,NULL,(zend_objects_free_object_storage_t) gnupg_keylistiterator_dtor,NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) & gnupg_keylistiterator_object_handlers; + gpgme_check_version(NULL); gpgme_new(&ctx); intern->ctx = ctx; return retval;