DavidKorczynski commited on
Commit
d9ee26f
·
1 Parent(s): 11bc9e6

ggml: fix div-by-zero (llama/9003)

Browse files

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=70724

In order to access the above bug you need to login using one of the
emails in
https://github.com/google/oss-fuzz/blob/master/projects/llamacpp/project.yaml#L3-L5

Signed-off-by: David Korczynski <[email protected]>

Files changed (1) hide show
  1. ggml/src/ggml.c +1 -1
ggml/src/ggml.c CHANGED
@@ -21700,7 +21700,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p
21700
  (int64_t) info->ne[2] *
21701
  (int64_t) info->ne[3];
21702
 
21703
- if (ne % ggml_blck_size(info->type) != 0) {
21704
  fprintf(stderr, "%s: tensor '%s' of type %d (%s) number of elements (%" PRId64 ") is not a multiple of block size (%" PRId64 ")\n",
21705
  __func__, info->name.data, (int) info->type, ggml_type_name(info->type), ne, ggml_blck_size(info->type));
21706
  fclose(file);
 
21700
  (int64_t) info->ne[2] *
21701
  (int64_t) info->ne[3];
21702
 
21703
+ if (ggml_blck_size(info->type) == 0 || ne % ggml_blck_size(info->type) != 0) {
21704
  fprintf(stderr, "%s: tensor '%s' of type %d (%s) number of elements (%" PRId64 ") is not a multiple of block size (%" PRId64 ")\n",
21705
  __func__, info->name.data, (int) info->type, ggml_type_name(info->type), ne, ggml_blck_size(info->type));
21706
  fclose(file);