Fix for a null pointer dereference if a metal GGML buffer fails to be allocated
This commit is contained in:
parent
2aed77eb06
commit
e9dcc37498
1 changed files with 10 additions and 6 deletions
|
@ -788,10 +788,12 @@ static bool alloc_tensor_range(struct ggml_context * ctx,
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "%s: failed to allocate %s buffer of size %zu\n", __func__, ggml_backend_buft_name(buft), size);
|
fprintf(stderr, "%s: failed to allocate %s buffer of size %zu\n", __func__, ggml_backend_buft_name(buft), size);
|
||||||
#endif
|
#endif
|
||||||
|
if (buffers && *buffers) {
|
||||||
for (size_t i = 0; i < *n_buffers; i++) {
|
for (size_t i = 0; i < *n_buffers; i++) {
|
||||||
ggml_backend_buffer_free(*buffers[i]);
|
ggml_backend_buffer_free(*buffers[i]);
|
||||||
}
|
}
|
||||||
free(buffers);
|
free(buffers);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,10 +845,12 @@ ggml_backend_buffer_t ggml_backend_alloc_ctx_tensors_from_buft(struct ggml_conte
|
||||||
__func__, t->name,
|
__func__, t->name,
|
||||||
ggml_backend_buft_name(buft),
|
ggml_backend_buft_name(buft),
|
||||||
this_size, max_size);
|
this_size, max_size);
|
||||||
|
if(buffers && *buffers) {
|
||||||
for (size_t i = 0; i < n_buffers; i++) {
|
for (size_t i = 0; i < n_buffers; i++) {
|
||||||
ggml_backend_buffer_free(buffers[i]);
|
ggml_backend_buffer_free(buffers[i]);
|
||||||
}
|
}
|
||||||
free(buffers);
|
free(buffers);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue