mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-11-07 16:44:13 +01:00
ggml: handle ggml_init failure to fix NULL pointer deref (llama/8692)
`ggml_init` can fail if no unused context is found. In that case, a NULL-pointer deref will happen later in the code during a call to `ggml_set_on_alloc`. This fixes it by bailing out if no context is found.
This commit is contained in:
parent
31d0a9a14f
commit
0620fe00ec
@ -21095,6 +21095,12 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p
|
|||||||
};
|
};
|
||||||
|
|
||||||
*params.ctx = ggml_init(pdata);
|
*params.ctx = ggml_init(pdata);
|
||||||
|
if (*params.ctx == NULL) {
|
||||||
|
fprintf(stderr, "%s: failed to initialize context\n", __func__);
|
||||||
|
fclose(file);
|
||||||
|
gguf_free(ctx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct ggml_context * ctx_data = *params.ctx;
|
struct ggml_context * ctx_data = *params.ctx;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user