Skip to content

Commit 32c54b5

Browse files
committed
Only update parms->cert on success
1 parent e25f05d commit 32c54b5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/eng_back.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ static int ENGINE_CTX_ctrl_load_cert(ENGINE_CTX *ctx, void *p)
315315
const char *s_slot_cert_id;
316316
X509 *cert;
317317
} *parms = p;
318+
X509 *cert;
318319

319320
if (!parms) {
320321
ENGerr(ENG_F_CTX_CTRL_LOAD_CERT, ERR_R_PASSED_NULL_PARAMETER);
@@ -326,23 +327,21 @@ static int ENGINE_CTX_ctrl_load_cert(ENGINE_CTX *ctx, void *p)
326327
}
327328

328329
pthread_mutex_lock(&ctx->lock);
329-
330330
/* Delayed libp11 initialization */
331331
if (!UTIL_CTX_init_libp11(ctx->util_ctx)) {
332332
ENGerr(ENG_F_CTX_LOAD_OBJECT, ENG_R_INVALID_PARAMETER);
333333
pthread_mutex_unlock(&ctx->lock);
334334
return 0;
335335
}
336-
337-
parms->cert = UTIL_CTX_get_cert_from_uri(ctx->util_ctx, parms->s_slot_cert_id);
338-
336+
cert = UTIL_CTX_get_cert_from_uri(ctx->util_ctx, parms->s_slot_cert_id);
339337
pthread_mutex_unlock(&ctx->lock);
340338

341-
if (!parms->cert) {
339+
if (!cert) {
342340
if (!ERR_peek_last_error())
343341
ENGerr(ENG_F_CTX_CTRL_LOAD_CERT, ENG_R_OBJECT_NOT_FOUND);
344342
return 0;
345343
}
344+
parms->cert = cert;
346345
return 1;
347346
}
348347

0 commit comments

Comments
 (0)