From 3eea011e056191d140d8b810d78420487a257b7a Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 20 May 2026 10:02:36 +0300 Subject: [PATCH] common/speculative : fix nullptr crash in get_devices_str ggml_backend_dev_by_name always appends a nullptr sentinel to the devices vector. Skipping nullptr entries prevents assertion failure in ggml_backend_dev_name. Assisted-by: llama.cpp:local pi --- common/speculative.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/common/speculative.cpp b/common/speculative.cpp index 4d1b61a13ad..6ca6bd29670 100644 --- a/common/speculative.cpp +++ b/common/speculative.cpp @@ -33,16 +33,15 @@ const std::map common_speculative_type_fro }; static std::string common_speculative_get_devices_str(const std::vector & devices) { - if (devices.empty()) { - return "default"; - } - std::string result; for (size_t i = 0; i < devices.size(); i++) { - if (i > 0) result += ", "; + if (devices[i] == nullptr) { + continue; + } + if (!result.empty()) result += ", "; result += ggml_backend_dev_name(devices[i]); } - return result; + return result.empty() ? "default" : result; } struct common_speculative_config {