Skip to content

Commit

Permalink
Modify Rule S4423[cfamily]: add nullptr check for libcurl examples
Browse files Browse the repository at this point in the history
Co-authored-by: Arseniy Zaostrovnykh <necto.ne@gmail.com>
  • Loading branch information
arseniy-sonar and necto authored May 28, 2024
1 parent bd355a1 commit d1e98e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rules/S4423/cfamily/how-to-fix-it/curl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
----

Expand All @@ -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);
}
}
----

Expand Down

0 comments on commit d1e98e9

Please sign in to comment.