summaryrefslogtreecommitdiff
path: root/src/csplit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/csplit.c')
-rw-r--r--src/csplit.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/csplit.c b/src/csplit.c
index 40baba825..57543f0a2 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -1372,10 +1372,11 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- if (suffix)
- filename_space = xmalloc (strlen (prefix) + max_out (suffix) + 2);
- else
- filename_space = xmalloc (strlen (prefix) + digits + 2);
+ unsigned int max_digit_string_len
+ = (suffix
+ ? max_out (suffix)
+ : MAX (INT_STRLEN_BOUND (unsigned int), digits));
+ filename_space = xmalloc (strlen (prefix) + max_digit_string_len + 1);
set_input_file (argv[optind++]);