make code cleaner than it was I when I started :)

This commit is contained in:
Jeremy Johnstone 2017-09-11 10:46:01 -06:00
parent e7cd93ba73
commit 2971456019

27
gnupg.c
View file

@ -1501,12 +1501,13 @@ PHP_FUNCTION(gnupg_messagekeys)
if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(&in, enctxt, enctxt_len, 0))) { if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(&in, enctxt, enctxt_len, 0))) {
GNUPG_ERR("could not create in-data buffer"); GNUPG_ERR("could not create in-data buffer");
RETURN_FALSE;
} }
if ((PHPC_THIS->err = gpgme_data_new(&out)) != GPG_ERR_NO_ERROR) { if ((PHPC_THIS->err = gpgme_data_new(&out)) != GPG_ERR_NO_ERROR) {
GNUPG_ERR("could not create out-data buffer"); GNUPG_ERR("could not create out-data buffer");
gpgme_data_release(in); gpgme_data_release(in);
return; RETURN_FALSE;
} }
PHP_GNUPG_DO(gpgme_op_decrypt(PHPC_THIS->ctx, in, out)); PHP_GNUPG_DO(gpgme_op_decrypt(PHPC_THIS->ctx, in, out));
@ -1516,19 +1517,19 @@ PHP_FUNCTION(gnupg_messagekeys)
gpgme_data_release(in); gpgme_data_release(in);
gpgme_data_release(out); gpgme_data_release(out);
if (result->recipients) { if (!result->recipients) {
PHPC_ARRAY_INIT(return_value);
recipient = result->recipients;
while (recipient) {
PHPC_ARRAY_ADD_ASSOC_BOOL(return_value, recipient->keyid, !recipient->status);
recipient = recipient->next;
}
} else {
GNUPG_ERR("invalid enctext"); GNUPG_ERR("invalid enctext");
RETVAL_FALSE; RETURN_FALSE;
}
PHPC_ARRAY_INIT(return_value);
recipient = result->recipients;
while (recipient) {
PHPC_ARRAY_ADD_ASSOC_BOOL(return_value, recipient->keyid, !recipient->status);
recipient = recipient->next;
} }
} }