Skip to content

Commit 38e58fa

Browse files
committed
Check return value from curl_easy_setopt
1 parent 3849bb6 commit 38e58fa

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/scitokens_internal.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,18 @@ class SimpleCurlGet {
5252
}
5353
}
5454

55-
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
56-
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data);
57-
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
55+
CURLcode rv = curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
56+
if (rv != CURLE_OK) {
57+
throw CurlException("Failed to set CURLOPT_URL.");
58+
}
59+
rv = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data);
60+
if (rv != CURLE_OK) {
61+
throw CurlException("Failed to set CURLOPT_WRITEFUNCTION.");
62+
}
63+
rv = curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
64+
if (rv != CURLE_OK) {
65+
throw CurlException("Failed to set CURLOPT_WRITEDATA.");
66+
}
5867

5968
auto res = curl_easy_perform(curl);
6069
if (res != CURLE_OK) {

0 commit comments

Comments
 (0)