Consider Strgrow overflow in Strinsert_char
This commit is contained in:
		
							
								
								
									
										4
									
								
								Str.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Str.c
									
									
									
									
									
								
							| @@ -348,10 +348,12 @@ Strinsert_char(Str s, int pos, char c) | ||||
| { | ||||
|     int i; | ||||
|     STR_LENGTH_CHECK(s); | ||||
|     if (pos < 0 || s->length < pos) | ||||
|     if (pos < 0) | ||||
| 	return; | ||||
|     if (s->length + 2 > s->area_size) | ||||
| 	Strgrow(s); | ||||
|     if (s->length < pos) | ||||
| 	return; | ||||
|     for (i = s->length; i > pos; i--) | ||||
| 	s->ptr[i] = s->ptr[i - 1]; | ||||
|     s->ptr[++s->length] = '\0'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user