File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ void Host_Repl() {
117
117
int input_len = 0 ;
118
118
REBYTE * input = OS_Make (input_max );
119
119
120
+ REBYTE * tmp ;
120
121
REBYTE * line ;
121
122
int line_len ;
122
123
@@ -191,15 +192,19 @@ void Host_Repl() {
191
192
inside_short_str = FALSE;
192
193
193
194
if (input_len + line_len > input_max ) {
194
- REBYTE * tmp = OS_Make (2 * input_max );
195
+ // limit maximum input size to 2GB (it should be more than enough)
196
+ if (input_max >= 0x80000000 ) goto crash_buffer ;
197
+ input_max *= 2 ;
198
+ tmp = OS_Make (input_max );
195
199
if (!tmp ) {
200
+ crash_buffer :
196
201
Put_Str (b_cast ("\x1B[0m" )); //reset console color;
197
202
Host_Crash ("Growing console input buffer failed!" );
203
+ return ; // make VS compiler happy
198
204
}
199
205
memcpy (tmp , input , input_len );
200
206
OS_Free (input );
201
207
input = tmp ;
202
- input_max *= 2 ;
203
208
}
204
209
205
210
memcpy (& input [input_len ], line , line_len );
You can’t perform that action at this time.
0 commit comments