Skip to content

Commit

Permalink
Fixing memory leak by freeing memory allocated by strdup in cert_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowrima committed Oct 30, 2024
1 parent 519512c commit b388e98
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions zookeeper-client/zookeeper-client-c/src/zookeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,6 @@ static zhandle_t *zookeeper_init_internal(const char *host, watcher_fn watcher,
if (cert) {
zh->fd->cert = calloc(1, sizeof(zcert_t));
memcpy(zh->fd->cert, cert, sizeof(zcert_t));
free(cert->certstr);
free(cert->ca);
}

#ifdef _WIN32
Expand Down Expand Up @@ -3875,6 +3873,7 @@ int zookeeper_close(zhandle_t *zh)
LOG_INFO(LOGCALLBACK(zh), "Freeing zookeeper resources for sessionId=%#llx\n", zh->client_id.client_id);
destroy(zh);
adaptor_destroy(zh);
free(zh->fd->cert);
free(zh->fd);
free(zh);
#ifdef _WIN32
Expand Down

0 comments on commit b388e98

Please sign in to comment.