← Commit list

121c540168

Viktor Szakats
Viktor Szakats
2025-12-08
SUCCESS Duration: 227s

Subject

sspi: fix memory leaks on error paths in `Curl_create_sspi_identity()`

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/curl_sspi.c+15 -7
@@ -135,33 +135,34 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
curlx_free(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
- identity->User = dup_user.tbyte_ptr;
- identity->UserLength = curlx_uztoul(_tcslen(dup_user.tchar_ptr));
- dup_user.tchar_ptr = NULL;
/* Setup the identity's domain and length */
dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1));
if(!dup_domain.tchar_ptr) {
+ curlx_free(dup_user.tchar_ptr);
curlx_free(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) {
+ curlx_free(dup_user.tchar_ptr);
curlx_free(dup_domain.tchar_ptr);
curlx_free(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
- identity->Domain = dup_domain.tbyte_ptr;
- identity->DomainLength = curlx_uztoul(domlen);
- dup_domain.tchar_ptr = NULL;
curlx_free(useranddomain.tchar_ptr);
/* Setup the identity's password and length */
passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp);
- if(!passwd.tchar_ptr)
+ if(!passwd.tchar_ptr) {
+ curlx_free(dup_user.tchar_ptr);
+ curlx_free(dup_domain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
+ }
dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr);
if(!dup_passwd.tchar_ptr) {
+ curlx_free(dup_user.tchar_ptr);
+ curlx_free(dup_domain.tchar_ptr);
curlx_free(passwd.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
@@ -171,6 +172,13 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
curlx_free(passwd.tchar_ptr);
+ identity->User = dup_user.tbyte_ptr;
+ identity->UserLength = curlx_uztoul(_tcslen(dup_user.tchar_ptr));
+ dup_user.tchar_ptr = NULL;
+ identity->Domain = dup_domain.tbyte_ptr;
+ identity->DomainLength = curlx_uztoul(domlen);
+ dup_domain.tchar_ptr = NULL;
+
/* Setup the identity's flags */
identity->Flags = (unsigned long)
#ifdef UNICODE