File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed 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 {
145145                pos++;
146146                last_sym_start = out_elements.size ();
147147                while  (*pos != ' "' 
148+                     if  (!*pos) {  //  [jart] don't sync until upstream fixes bug
149+                         throw  std::runtime_error (" unexpected end of input" 
150+                     }
148151                    auto  char_pair = parse_char (pos);
149152                         pos       = char_pair.second ;
150153                    out_elements.push_back ({LLAMA_GRETYPE_CHAR, char_pair.first });
@@ -159,6 +162,9 @@ namespace grammar_parser {
159162                }
160163                last_sym_start = out_elements.size ();
161164                while  (*pos != ' ]' 
165+                     if  (!*pos) {  //  [jart] don't sync until upstream fixes bug
166+                         throw  std::runtime_error (" unexpected end of input" 
167+                     }
162168                    auto  char_pair = parse_char (pos);
163169                         pos       = char_pair.second ;
164170                    enum  llama_gretype type = last_sym_start < out_elements.size ()
@@ -167,6 +173,9 @@ namespace grammar_parser {
167173
168174                    out_elements.push_back ({type, char_pair.first });
169175                    if  (pos[0 ] == ' -' 1 ] != ' ]' 
176+                         if  (pos[1 ]) {  //  [jart] don't sync until upstream fixes bug
177+                             throw  std::runtime_error (" unexpected end of input" 
178+                         }
170179                        auto  endchar_pair = parse_char (pos + 1 );
171180                             pos          = endchar_pair.second ;
172181                        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
866866            }
867867        }
868868
869-         if  (slot->ctx_sampling  != nullptr )
870-         {
869+         if  (slot->ctx_sampling  != nullptr ) {
871870            llama_sampling_free (slot->ctx_sampling );
872871        }
873872        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
875875            LOG_TEE (" %s: failed to initialize sampling subsystem\n " 
876876            return  false ;
877877        }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments