summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1994-12-03 11:26:51 +0000
committerVern Paxson <vern@ee.lbl.gov>1994-12-03 11:26:51 +0000
commit585dbc08504da06e156b385615f4b11a50d55d3d (patch)
tree7de417aa11b917104f31587abe0ed90e73ea6497 /misc.c
parent10b195c219b555ee449c913372193b143b672776 (diff)
Increase slowly if realloc double overflows
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c11
1 files changed, 10 insertions, 1 deletions
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 );
}