]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
common/speculative : fix nullptr crash in get_devices_str (#23386)
authorGeorgi Gerganov <redacted>
Wed, 20 May 2026 16:44:30 +0000 (19:44 +0300)
committerGitHub <redacted>
Wed, 20 May 2026 16:44:30 +0000 (19:44 +0300)
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

index 4d1b61a13ad95f5aa9c3922a2f6c59c4437adf57..6ca6bd29670e3e7cb68644e2e89c0109d0736bc9 100644 (file)
@@ -33,16 +33,15 @@ const std::map<std::string, common_speculative_type> common_speculative_type_fro
 };
 
 static std::string common_speculative_get_devices_str(const std::vector<ggml_backend_dev_t> & 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 {