From f43c24d2c0a2246de1ad63985825dcf7764395ee Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 28 Oct 2024 22:14:50 +0100 Subject: [PATCH] set _errbuf to the empty string before use --- cpp/include/kvikio/shim/libcurl.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/include/kvikio/shim/libcurl.hpp b/cpp/include/kvikio/shim/libcurl.hpp index cee50c5947..2d717a7caa 100644 --- a/cpp/include/kvikio/shim/libcurl.hpp +++ b/cpp/include/kvikio/shim/libcurl.hpp @@ -150,7 +150,7 @@ class CurlHandle { /** * @brief Construct a new curl handle. * - * Typically, do not use this directly instead use the `create_curl_handle()` macro. + * Typically, do not call this directly instead use the `create_curl_handle()` macro. * * @param handle An unused curl easy handle pointer, which is retained on destruction. * @param source_file Path of source file of the caller (for error messages). @@ -166,6 +166,7 @@ class CurlHandle { setopt(CURLOPT_NOSIGNAL, 1L); // We always set CURLOPT_ERRORBUFFER to get better error messages. + _errbuf[0] = 0; // Set the error buffer as empty. setopt(CURLOPT_ERRORBUFFER, _errbuf); // Make curl_easy_perform() fail when receiving HTTP code errors. @@ -216,7 +217,7 @@ class CurlHandle { // Perform the curl operation and check for errors. CURLcode err = curl_easy_perform(handle()); if (err != CURLE_OK) { - std::string msg(_errbuf); + std::string msg(_errbuf); // We can do this because we always initialize `_errbuf` as empty. std::stringstream ss; ss << "curl_easy_perform() error near " << _source_file << ":" << _source_line; if (msg.empty()) {