Skip to content

Commit 1d86bd8

Browse files
authored
Fix --split-max-size
Byte size calculation was done on int and overflowed.
1 parent ab9a324 commit 1d86bd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/gguf-split/gguf-split.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ static size_t split_str_to_n_bytes(std::string str) {
5959
int n;
6060
if (str.back() == 'M') {
6161
sscanf(str.c_str(), "%d", &n);
62-
n_bytes = n * 1024 * 1024; // megabytes
62+
n_bytes = (size_t)n * 1024 * 1024; // megabytes
6363
} else if (str.back() == 'G') {
6464
sscanf(str.c_str(), "%d", &n);
65-
n_bytes = n * 1024 * 1024 * 1024; // gigabytes
65+
n_bytes = (size_t)n * 1024 * 1024 * 1024; // gigabytes
6666
} else {
6767
throw std::invalid_argument("error: supported units are M (megabytes) or G (gigabytes), but got: " + std::string(1, str.back()));
6868
}

0 commit comments

Comments
 (0)