diff options
author | Explorer09 <explorer09@gmail.com> | 2017-10-13 16:59:26 +0800 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2017-12-06 16:23:25 -0500 |
commit | 23882383d45dcd37b5177835c873f4e1d9582db1 (patch) | |
tree | 09afc0359b03f5fb6a6d220e8f0ced8b9d100dea | |
parent | 08e1b25b0ec17d4312f838efc6f910b64900b009 (diff) |
scanner: prevent overflow in add_action()
-rw-r--r-- | src/misc.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -116,15 +116,14 @@ void add_action (const char *new_text) int len = (int) strlen (new_text); while (len + action_index >= action_size - 10 /* slop */ ) { - int new_size = action_size * 2; - if (new_size <= 0) + if (action_size > INT_MAX / 2) /* Increase just a little, to try to avoid overflow * on 16-bit machines. */ action_size += action_size / 8; else - action_size = new_size; + action_size = action_size * 2; action_array = reallocate_character_array (action_array, |