void-packages/srcpkgs/detox/patches/detox-1.2.0.fix-invalid-mem...

25 lines
844 B
Diff
Raw Normal View History

2015-05-26 13:54:33 +02:00
diff -up detox-1.2.0/parse_options_getopt.c.dt detox-1.2.0/parse_options_getopt.c
--- detox-1.2.0/parse_options_getopt.c.dt 2010-07-05 09:52:45.409372974 +0200
+++ detox-1.2.0/parse_options_getopt.c 2010-07-05 10:02:55.698264851 +0200
@@ -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++;
}