ggml_used_mem can segfault if called before any objects are created.

This commit is contained in:
KerfuffleV2 2023-05-01 04:21:33 -06:00
parent 90b19bd6ee
commit acae41c7ac

2
ggml.c
View file

@ -4411,7 +4411,7 @@ void ggml_free(struct ggml_context * ctx) {
}
size_t ggml_used_mem(const struct ggml_context * ctx) {
return ctx->objects_end->offs + ctx->objects_end->size;
return ctx->objects_end == NULL ? 0 : ctx->objects_end->offs + ctx->objects_end->size;
}
size_t ggml_set_scratch(struct ggml_context * ctx, struct ggml_scratch scratch) {