Skip to content

Commit

Permalink
Removing heap memory allocation for cert.ca using strdup() since strt…
Browse files Browse the repository at this point in the history
…ok() doesn't always return a pointer to the heap allocated memory.
  • Loading branch information
Gowrima committed Nov 28, 2024
1 parent 264cec2 commit 441ec15
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 @@ -692,7 +692,6 @@ static void destroy(zhandle_t *zh)
#ifdef HAVE_OPENSSL_H
if (zh->fd->cert) {
free(zh->fd->cert->certstr);
free(zh->fd->cert->ca);
free(zh->fd->cert);
zh->fd->cert = NULL;
}
Expand Down Expand Up @@ -1455,7 +1454,7 @@ zhandle_t *zookeeper_init_ssl(const char *host, const char *cert, watcher_fn wat
{
zcert_t zcert;
zcert.certstr = strdup(cert);
zcert.ca = strtok(strdup(cert), ",");
zcert.ca = strtok(zcert.certstr, ",");
zcert.cert = strtok(NULL, ",");
zcert.key = strtok(NULL, ",");
zcert.passwd = strtok(NULL, ",");
Expand Down

0 comments on commit 441ec15

Please sign in to comment.