common : fix incorrect uses of stoul (#20313)

This commit is contained in:
Sigbjørn Skjæret 2026-03-10 11:40:26 +01:00 committed by GitHub
parent 0cd4f4720b
commit ec947d2b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -2427,11 +2427,11 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
); );
} }
if (split_arg.size() == 1) { if (split_arg.size() == 1) {
std::fill(params.fit_params_target.begin(), params.fit_params_target.end(), std::stoul(split_arg[0]) * 1024*1024); std::fill(params.fit_params_target.begin(), params.fit_params_target.end(), std::stoull(split_arg[0]) * 1024*1024);
return; return;
} }
for (size_t i = 0; i < split_arg.size(); i++) { for (size_t i = 0; i < split_arg.size(); i++) {
params.fit_params_target[i] = std::stoul(split_arg[i]) * 1024*1024; params.fit_params_target[i] = std::stoull(split_arg[i]) * 1024*1024;
} }
} }
).set_env("LLAMA_ARG_FIT_TARGET")); ).set_env("LLAMA_ARG_FIT_TARGET"));

View File

@ -790,7 +790,7 @@ public:
} else if (target.is_array()) { } else if (target.is_array()) {
size_t sel_index; size_t sel_index;
try { try {
sel_index = std::stoul(sel); sel_index = std::stoull(sel);
} catch (const std::invalid_argument & e) { } catch (const std::invalid_argument & e) {
sel_index = target.size(); sel_index = target.size();
} }

View File

@ -601,7 +601,7 @@ const char * llama_grammar_parser::parse_sequence(
throw std::runtime_error(std::string("expecting an int at ") + pos); throw std::runtime_error(std::string("expecting an int at ") + pos);
} }
const char * int_end = parse_int(pos); const char * int_end = parse_int(pos);
uint64_t min_times = std::stoul(std::string(pos, int_end - pos)); uint64_t min_times = std::stoull(std::string(pos, int_end - pos));
pos = parse_space(int_end, is_nested); pos = parse_space(int_end, is_nested);
uint64_t max_times = UINT64_MAX; // default: no max limit uint64_t max_times = UINT64_MAX; // default: no max limit
@ -614,7 +614,7 @@ const char * llama_grammar_parser::parse_sequence(
if (is_digit_char(*pos)) { if (is_digit_char(*pos)) {
const char * int_end = parse_int(pos); const char * int_end = parse_int(pos);
max_times = std::stoul(std::string(pos, int_end - pos)); max_times = std::stoull(std::string(pos, int_end - pos));
pos = parse_space(int_end, is_nested); pos = parse_space(int_end, is_nested);
} }