error checking and ensure we check version

This commit is contained in:
Jim Jagielski 2013-07-17 12:54:49 +00:00
parent 0bfb5d8a50
commit 48472e9516
2 changed files with 7 additions and 3 deletions

View file

@ -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;

View file

@ -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;