Browse Source

ZOOKEEPER-3944: Fix sasl memory leak

Within ```zoo_sasl_client_destroy```, it carefully free all members of the sasl client, while here it doesn't free the struct itself before set it to NULL. This error is detected by leak sanitizer.

Author: Xiaotian <523950475@qq.com>

Reviewers: Damien Diederen <dd@crosstwine.com>, Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes #1466 from xiaotian-qi/ZOOKEEPER-3944
Xiaotian 4 years ago
parent
commit
38f8e1bff2
1 changed files with 1 additions and 0 deletions
  1. 1 0
      zookeeper-client/zookeeper-client-c/src/zookeeper.c

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

@@ -694,6 +694,7 @@ static void destroy(zhandle_t *zh)
 #ifdef HAVE_CYRUS_SASL_H
     if (zh->sasl_client) {
         zoo_sasl_client_destroy(zh->sasl_client);
+        free(zh->sasl_client);
         zh->sasl_client = NULL;
     }
 #endif /* HAVE_CYRUS_SASL_H */