Skip to content

Conversation

@nihiragarwal24
Copy link

@nihiragarwal24 nihiragarwal24 commented Dec 25, 2025

Fix memory leak in zoo_sasl_client_create on failure

zoo_sasl_client_create allocates a zoo_sasl_client_t and then duplicates several strings. If any duplication fails (e.g. due to OOM), the function calls zoo_sasl_client_destroy(sc) and returns NULL.

However, zoo_sasl_client_destroy only frees internal members and does not free the structure itself, resulting in a memory leak on every failed initialization attempt.

Impact: Repeated SASL initialization retries under transient allocation failures can cause unbounded memory growth and eventual OOM.

Fix: Explicitly free the allocated structure in the error path.

zoo_sasl_client_destroy(sc);
free(sc);
return NULL;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant