Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggml : fix null backend dereference #4807

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ggml-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ ggml_backend_t ggml_backend_cpu_init(void) {
}

bool ggml_backend_is_cpu(ggml_backend_t backend) {
return backend->iface.get_name == ggml_backend_cpu_name;
return backend && backend->iface.get_name == ggml_backend_cpu_name;
}

void ggml_backend_cpu_set_n_threads(ggml_backend_t backend_cpu, int n_threads) {
Expand Down
2 changes: 1 addition & 1 deletion ggml-cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10140,7 +10140,7 @@ ggml_backend_t ggml_backend_cuda_init(int device) {
}

bool ggml_backend_is_cuda(ggml_backend_t backend) {
return backend->iface.get_name == ggml_backend_cuda_name;
return backend && backend->iface.get_name == ggml_backend_cuda_name;
}

int ggml_backend_cuda_get_device_count() {
Expand Down
2 changes: 1 addition & 1 deletion ggml-metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,7 @@ ggml_backend_t ggml_backend_metal_init(void) {
}

bool ggml_backend_is_metal(ggml_backend_t backend) {
return backend->iface.get_name == ggml_backend_metal_name;
return backend && backend->iface.get_name == ggml_backend_metal_name;
}

void ggml_backend_metal_set_n_cb(ggml_backend_t backend, int n_cb) {
Expand Down
Loading