]> granicus.if.org Git - flex/commitdiff
Increase slowly if realloc double overflows
authorVern Paxson <vern@ee.lbl.gov>
Sat, 3 Dec 1994 11:26:51 +0000 (11:26 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sat, 3 Dec 1994 11:26:51 +0000 (11:26 +0000)
misc.c

diff --git a/misc.c b/misc.c
index 4d98070017067ad19ac05e9cf5211cf1a8fd5429..8cca84243c2710c4ac07b1204baa28e64318243e 100644 (file)
--- 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 );
                }