Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/gguf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,10 @@ static struct gguf_context * gguf_init_from_reader(const struct gguf_reader & gr
ok = ok && gr.read(info.t.ne[j]);
}

// check that all ne are non-negative
if (info.t.ne[j] < 0) {
GGML_LOG_ERROR("%s: tensor '%s' dimension %" PRIu32 " has invalid number of elements: %" PRIi64 " < 0\n",
// check that all ne are positive (ne == 0 causes division by zero
// in the overflow check below: INT64_MAX/ne[1], INT64_MAX/ne[2], etc.)
if (info.t.ne[j] <= 0) {
GGML_LOG_ERROR("%s: tensor '%s' dimension %" PRIu32 " has invalid number of elements: %" PRIi64 " <= 0\n",
__func__, info.t.name, j, info.t.ne[j]);
ok = false;
break;
Expand Down