Modify Rule S4423[cfamily]: add nullptr check for libcurl examples

Co-authored-by: Arseniy Zaostrovnykh <necto.ne@gmail.com>
This commit is contained in:
Arseniy Zaostrovnykh 2024-05-28 14:46:07 +02:00 committed by GitHub
parent bd355a1e03
commit d1e98e9eb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,9 +18,11 @@ void encrypt() {
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init(); // Noncompliant
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_perform(curl);
curl_easy_perform(curl);
}
}
----
@ -35,10 +37,12 @@ void encrypt() {
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_easy_perform(curl);
curl_easy_perform(curl);
}
}
----