Browse Source

ZOOKEEPER-4020: Fix memory leak from ssl cert in c client

Reviewers: kezhuw
Author: Gowrima
Closes #2209 from Gowrima/ZOOKEEPER-4020
Gowrima 4 months ago
parent
commit
f7af2acd7f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      zookeeper-client/zookeeper-client-c/src/zookeeper.c

+ 1 - 1
zookeeper-client/zookeeper-client-c/src/zookeeper.c

@@ -1454,7 +1454,7 @@ zhandle_t *zookeeper_init_ssl(const char *host, const char *cert, watcher_fn wat
 {
 {
     zcert_t zcert;
     zcert_t zcert;
     zcert.certstr = strdup(cert);
     zcert.certstr = strdup(cert);
-    zcert.ca = strtok(strdup(cert), ",");
+    zcert.ca = strtok(zcert.certstr, ",");
     zcert.cert = strtok(NULL, ",");
     zcert.cert = strtok(NULL, ",");
     zcert.key = strtok(NULL, ",");
     zcert.key = strtok(NULL, ",");
     zcert.passwd = strtok(NULL, ",");       
     zcert.passwd = strtok(NULL, ",");