1
0
mirror of synced 2025-01-18 09:04:52 +01:00

fix: Undefined behaviour in helper functions

This commit is contained in:
WerWolv 2022-08-16 00:12:28 +02:00 committed by GitHub
parent 07dc77f13d
commit 43ab72dcb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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) {

View File

@ -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) {