]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openldap: fix memory-leak on oldap_do's exit path
authorDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 20:57:29 +0000 (22:57 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 21:28:00 +0000 (23:28 +0200)
On SSL sockbuf setup failure in `oldap_do`, the 'lud' data would not be
freed and instead leak.

Reported-by: Joshua Rogers
Closes #18986

lib/openldap.c

index 92364e3e77c993014503d976613ff083949a0404..b84268dae7c0d58245bb7eb15b478d7941865d55 100644 (file)
@@ -988,8 +988,10 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done)
     Sockbuf *sb;
     /* re-install the libcurl SSL handlers into the sockbuf. */
     if((ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb) != LDAP_OPT_SUCCESS) ||
-       ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data))
+       ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data)) {
+      ldap_free_urldesc(lud);
       return CURLE_FAILED_INIT;
+    }
   }
 #endif