fixing potential NULL dereference in reading GGUF file
This commit is contained in:
parent
94496cd49c
commit
7e60415bc9
1 changed files with 8 additions and 2 deletions
|
@ -92,7 +92,10 @@ static bool gguf_ex_read_0(const std::string & fname) {
|
|||
};
|
||||
|
||||
struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);
|
||||
|
||||
if (NULL == ctx) {
|
||||
fprintf(stderr, "could not retrieve GGUF data context from file.\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s: version: %d\n", __func__, gguf_get_version(ctx));
|
||||
printf("%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx));
|
||||
printf("%s: data offset: %zu\n", __func__, gguf_get_data_offset(ctx));
|
||||
|
@ -152,7 +155,10 @@ static bool gguf_ex_read_1(const std::string & fname) {
|
|||
};
|
||||
|
||||
struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);
|
||||
|
||||
if (NULL == ctx) {
|
||||
fprintf(stderr, "could not retrieve GGUF data context from file.\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s: version: %d\n", __func__, gguf_get_version(ctx));
|
||||
printf("%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx));
|
||||
printf("%s: data offset: %zu\n", __func__, gguf_get_data_offset(ctx));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue