6c73622506
Closes #13558. Signed-off-by: Enno Boland <gottox@voidlinux.eu>
23 lines
660 B
Diff
23 lines
660 B
Diff
--- src/parse_options.c.dt
|
|
+++ src/parse_options.c
|
|
@@ -178,15 +178,17 @@ struct detox_options *parse_options_geto
|
|
main_options->files = malloc(sizeof(char *) * 10);
|
|
|
|
i = 0;
|
|
- max = 0;
|
|
+ max = 10;
|
|
|
|
if (optind < argc) {
|
|
while (optind < argc) {
|
|
- main_options->files[i++] = strdup(argv[optind]);
|
|
- if (i > max) {
|
|
+ /* not enough space for the next file and
|
|
+ possible ending NULL -> realloc */
|
|
+ if (i + 2 > max) {
|
|
main_options->files = realloc(main_options->files, sizeof(char *) * (10 + max));
|
|
max += 10;
|
|
}
|
|
+ main_options->files[i++] = strdup(argv[optind]);
|
|
|
|
optind++;
|
|
}
|