common: add bounds check in common_init_result::sampler to prevent segfault on failed model load (#21082)

* common: add bounds check in common_init_result::sampler to prevent segfault on failed model load

* Revert a308e584ca

* Add regression test

* Remove regression test for init-fail sampler check
This commit is contained in:
mtmcp authored and GitHub committed 2026-03-31 13:04:42 +03:00
1 parent fcc2d598c8
commit 90aa83c6bd
2 files changed
+4 -7

No files matched your search

+3
View File
@@ -1243,6 +1243,9 @@ llama_context * common_init_result::context() {
}
common_sampler * common_init_result::sampler(llama_seq_id seq_id) {
if (seq_id < 0 || seq_id >= (int) pimpl->samplers.size()) {
return nullptr;
}
return pimpl->samplers[seq_id].get();
}