esp_http_client: fix coverity issue. free `auth_str` before going out of scope

pull/10546/head
Harshit Malpani 2023-01-11 16:57:04 +05:30
rodzic 1d2469fbd1
commit 3152fba654
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FF1193D150EF75C3
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -126,12 +126,13 @@ char *http_auth_digest(const char *username, const char *password, esp_http_auth
}
if (auth_data->opaque) {
rc = asprintf(&temp_auth_str, "%s, opaque=\"%s\"", auth_str, auth_data->opaque);
// Free the previous memory allocated for `auth_str`
free(auth_str);
if (rc < 0) {
ESP_LOGE(TAG, "asprintf() returned: %d", rc);
ret = ESP_FAIL;
goto _digest_exit;
}
free(auth_str);
auth_str = temp_auth_str;
}
_digest_exit: