]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openldap: fix memory-leak in error path
authorDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 20:50:01 +0000 (22:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 21:27:08 +0000 (23:27 +0200)
The 'ber' pointer could escape a free if an early error occurred.

Reported-by: Joshua Rogers
Closes #18985

lib/openldap.c

index 72cfdc7039a8ab6cefa7a0eaed51497ecf9316d1..92364e3e77c993014503d976613ff083949a0404 100644 (file)
@@ -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;
 }