Skip to content

Commit cb0d3b8

Browse files
committed
avoid dub-free
1 parent e8d23e0 commit cb0d3b8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/ziti.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,13 +1583,15 @@ static void ca_bundle_cb(char *pkcs7, const ziti_error *err, void *ctx) {
15831583
goto error;
15841584
}
15851585

1586-
if (ztx->config.id.ca && strcmp(new_pem, ztx->config.id.ca) != 0) {
1586+
if (ztx->config.id.ca == NULL || strcmp(new_pem, ztx->config.id.ca) != 0) {
1587+
ztx->tlsCtx->set_ca_bundle(ztx->tlsCtx, new_pem, strlen(new_pem));
15871588
char *old_ca = (char*)ztx->config.id.ca;
1589+
free(old_ca);
1590+
15881591
ztx->config.id.ca = new_pem;
1592+
new_pem = NULL;
15891593

1590-
ztx->tlsCtx->set_ca_bundle(ztx->tlsCtx, new_pem, strlen(new_pem));
15911594
ztx_config_update(ztx);
1592-
free(old_ca);
15931595
}
15941596
} else {
15951597
ZITI_LOG(ERROR, "failed to get CA bundle from controller: %s", err->message);

0 commit comments

Comments
 (0)