Use std::strtoll instead of std::stol

This commit is contained in:
kannibalox
2024-10-27 16:47:50 -04:00
committed by Jari Sundell
parent c18df7a366
commit b360a734f1
2 changed files with 10 additions and 1 deletions
+6 -1
View File
@@ -115,7 +115,12 @@ xml_value_to_object(const tinyxml2::XMLNode* elem) {
}
return torrent::Object(value_element_child->ToText()->Value());
} else if (value_element_type == "i4" || value_element_type == "i8" || value_element_type == "int") {
return torrent::Object(std::stol(std::string(value_element->FirstChild()->ToText()->Value())));
char* pos;
auto str = value_element->FirstChild()->ToText()->Value();
auto result = std::strtoll(str, &pos, 10);
if (pos == str || *pos != '\0')
throw xmlrpc_error(XMLRPC_TYPE_ERROR, "unable to parse integer value");
return torrent::Object(result);
} else if (value_element_type == "boolean") {
auto boolean_text = std::string(value_element->FirstChild()->ToText()->Value());
if (boolean_text == "1") {