fix: Undefined behaviour in helper functions
This commit is contained in:
parent
07dc77f13d
commit
43ab72dcb8
@ -90,7 +90,7 @@ namespace hex::fs {
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
auto cString = reinterpret_cast<const char *>(bytes.data());
|
auto cString = reinterpret_cast<const char *>(bytes.data());
|
||||||
return { cString, std::min(bytes.size(), std::strlen(cString)) };
|
return { cString, std::strnlen(cString, bytes.size()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
std::u8string File::readU8String(size_t numBytes) {
|
std::u8string File::readU8String(size_t numBytes) {
|
||||||
|
@ -124,7 +124,7 @@ namespace hex {
|
|||||||
if (result != CURLE_OK)
|
if (result != CURLE_OK)
|
||||||
log::error("Net request failed with error {0}: '{1}'", u32(result), curl_easy_strerror(result));
|
log::error("Net request failed with error {0}: '{1}'", u32(result), curl_easy_strerror(result));
|
||||||
|
|
||||||
i32 responseCode = 0;
|
long responseCode = 0;
|
||||||
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||||
|
|
||||||
curl_slist_free_all(this->m_headers);
|
curl_slist_free_all(this->m_headers);
|
||||||
@ -135,7 +135,7 @@ namespace hex {
|
|||||||
if (result != CURLE_OK)
|
if (result != CURLE_OK)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
else
|
else
|
||||||
return responseCode;
|
return i32(responseCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::future<Response<std::string>> Net::getString(const std::string &url, u32 timeout) {
|
std::future<Response<std::string>> Net::getString(const std::string &url, u32 timeout) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user