From: Daniel Stenberg Date: Thu, 9 Oct 2025 20:50:01 +0000 (+0200) Subject: openldap: fix memory-leak in error path X-Git-Tag: rc-8_17_0-1~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d35bdfa8f28d646166592f607b8100b6c60be0f0;p=thirdparty%2Fcurl.git openldap: fix memory-leak in error path The 'ber' pointer could escape a free if an early error occurred. Reported-by: Joshua Rogers Closes #18985 --- diff --git a/lib/openldap.c b/lib/openldap.c index 72cfdc7039..92364e3e77 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -1216,7 +1216,6 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, break; } - ber_free(ber, 0); if(!result) result = client_write(data, STRCONST("\n"), NULL, 0, NULL, 0); @@ -1225,6 +1224,7 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, break; } + ber_free(ber, 0); ldap_msgfree(msg); return result; }