File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ namespace grammar_parser {
145
145
pos++;
146
146
last_sym_start = out_elements.size ();
147
147
while (*pos != ' "' ) {
148
+ if (!*pos) { // [jart] don't sync until upstream fixes bug
149
+ throw std::runtime_error (" unexpected end of input" );
150
+ }
148
151
auto char_pair = parse_char (pos);
149
152
pos = char_pair.second ;
150
153
out_elements.push_back ({LLAMA_GRETYPE_CHAR, char_pair.first });
@@ -159,6 +162,9 @@ namespace grammar_parser {
159
162
}
160
163
last_sym_start = out_elements.size ();
161
164
while (*pos != ' ]' ) {
165
+ if (!*pos) { // [jart] don't sync until upstream fixes bug
166
+ throw std::runtime_error (" unexpected end of input" );
167
+ }
162
168
auto char_pair = parse_char (pos);
163
169
pos = char_pair.second ;
164
170
enum llama_gretype type = last_sym_start < out_elements.size ()
@@ -167,6 +173,9 @@ namespace grammar_parser {
167
173
168
174
out_elements.push_back ({type, char_pair.first });
169
175
if (pos[0 ] == ' -' && pos[1 ] != ' ]' ) {
176
+ if (pos[1 ]) { // [jart] don't sync until upstream fixes bug
177
+ throw std::runtime_error (" unexpected end of input" );
178
+ }
170
179
auto endchar_pair = parse_char (pos + 1 );
171
180
pos = endchar_pair.second ;
172
181
out_elements.push_back ({LLAMA_GRETYPE_CHAR_RNG_UPPER, endchar_pair.first });
Original file line number Diff line number Diff line change @@ -866,12 +866,12 @@ struct llama_server_context
866
866
}
867
867
}
868
868
869
- if (slot->ctx_sampling != nullptr )
870
- {
869
+ if (slot->ctx_sampling != nullptr ) {
871
870
llama_sampling_free (slot->ctx_sampling );
872
871
}
873
872
slot->ctx_sampling = llama_sampling_init (slot->sparams );
874
- if (!slot->ctx_sampling ) { // [jart] fixes crash
873
+ if (slot->ctx_sampling == nullptr ) {
874
+ // for now, the only error that may happen here is invalid grammar
875
875
LOG_TEE (" %s: failed to initialize sampling subsystem\n " , __func__);
876
876
return false ;
877
877
}
You can’t perform that action at this time.
0 commit comments