fix use-after-free on NULLing CB field if CB itself destroyed our context already

This commit is contained in:
Christian Grothoff 2016-01-01 20:52:56 +01:00
parent 20f8e9c73c
commit 00612f5e19

View File

@ -603,6 +603,7 @@ keys_completed_cb (void *cls,
struct TALER_MINT_Handle *mint = kr->mint; struct TALER_MINT_Handle *mint = kr->mint;
json_t *resp_obj; json_t *resp_obj;
long response_code; long response_code;
TALER_MINT_CertificationCallback cb;
resp_obj = MAC_download_get_result (&kr->db, resp_obj = MAC_download_get_result (&kr->db,
eh, eh,
@ -638,11 +639,11 @@ keys_completed_cb (void *cls,
free_keys_request (kr); free_keys_request (kr);
mint->state = MHS_FAILED; mint->state = MHS_FAILED;
/* notify application that we failed */ /* notify application that we failed */
if (NULL != mint->cert_cb) if (NULL != (cb = mint->cert_cb))
{ {
mint->cert_cb (mint->cert_cb_cls,
NULL);
mint->cert_cb = NULL; mint->cert_cb = NULL;
cb (mint->cert_cb_cls,
NULL);
} }
return; return;
} }
@ -650,11 +651,11 @@ keys_completed_cb (void *cls,
free_keys_request (kr); free_keys_request (kr);
mint->state = MHS_CERT; mint->state = MHS_CERT;
/* notify application about the key information */ /* notify application about the key information */
if (NULL != mint->cert_cb) if (NULL != (cb = mint->cert_cb))
{ {
mint->cert_cb (mint->cert_cb_cls,
&mint->key_data);
mint->cert_cb = NULL; mint->cert_cb = NULL;
cb (mint->cert_cb_cls,
&mint->key_data);
} }
} }