Skip to content

Commit 510b5c2

Browse files
authored
common/speculative : fix nullptr crash in get_devices_str (#23386)
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
1 parent a8681a0 commit 510b5c2

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

common/speculative.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ const std::map<std::string, common_speculative_type> common_speculative_type_fro
3333
};
3434

3535
static std::string common_speculative_get_devices_str(const std::vector<ggml_backend_dev_t> & devices) {
36-
if (devices.empty()) {
37-
return "default";
38-
}
39-
4036
std::string result;
4137
for (size_t i = 0; i < devices.size(); i++) {
42-
if (i > 0) result += ", ";
38+
if (devices[i] == nullptr) {
39+
continue;
40+
}
41+
if (!result.empty()) result += ", ";
4342
result += ggml_backend_dev_name(devices[i]);
4443
}
45-
return result;
44+
return result.empty() ? "default" : result;
4645
}
4746

4847
struct common_speculative_config {

0 commit comments

Comments
 (0)