From 585dbc08504da06e156b385615f4b11a50d55d3d Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sat, 3 Dec 1994 11:26:51 +0000 Subject: [PATCH] Increase slowly if realloc double overflows --- misc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/misc.c b/misc.c index 4d98070..8cca842 100644 --- a/misc.c +++ b/misc.c @@ -63,7 +63,16 @@ char *new_text; while ( len + action_index >= action_size - 10 /* slop */ ) { - action_size *= 2; + int new_size = action_size * 2; + + if ( new_size <= 0 ) + /* Increase just a little, to try to avoid overflow + * on 16-bit machines. + */ + action_size += action_size / 8; + else + action_size = new_size; + action_array = reallocate_character_array( action_array, action_size ); } -- 2.50.1