check if samplers size > seq id before access
This commit is contained in:
parent
0c21677e43
commit
207eb94a51
|
|
@ -1195,6 +1195,9 @@ llama_context * common_init_result::context() {
|
|||
}
|
||||
|
||||
common_sampler * common_init_result::sampler(llama_seq_id seq_id) {
|
||||
if (pimpl->samplers.size() <= (size_t) seq_id) {
|
||||
return nullptr;
|
||||
}
|
||||
return pimpl->samplers[seq_id].get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,10 @@ int main(int argc, char ** argv) {
|
|||
ctx = llama_init->context();
|
||||
model = llama_init->model();
|
||||
smpl = llama_init->sampler(0);
|
||||
if (smpl == NULL) {
|
||||
LOG_ERR("%s: error: unable to create sampler\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctx == NULL) {
|
||||
LOG_ERR("%s: error: unable to create context\n", __func__);
|
||||
|
|
|
|||
Loading…
Reference in New Issue