[tools/peerindex] Prevent possible clobbering of argc,argv after longjmp()

pull/2/head
Lorenzo Cogotti 3 years ago
parent db129a0d39
commit 7be90e6e87

@ -407,20 +407,23 @@ int main(int argc, char **argv)
argc -= optind; argc -= optind;
argv += optind; argv += optind;
// Move to filtering rules and compile them // Take file list
if (argc == 0) { char **files = argv;
int nfiles = argc;
if (nfiles == 0) {
// If no FILES are provided, read from stdin // If no FILES are provided, read from stdin
static const char *const stdinFile[] = { "-" }; static const char *const stdinFile[] = { "-" };
argv = (char **) stdinFile; files = (char **) stdinFile;
argc = ARRAY_SIZE(stdinFile); nfiles = ARRAY_SIZE(stdinFile);
} }
volatile int i = 0; volatile int i = 0;
setjmp(S.dropFileFrame); // NOTE: The ONLY place where this is set setjmp(S.dropFileFrame); // NOTE: The ONLY place where this is set
while (i < argc) while (i < nfiles)
Peerindex_ProcessMrtDump(argv[i++]); Peerindex_ProcessMrtDump(files[i++]);
if (S.outfOps->Close) S.outfOps->Close(S.outf); if (S.outfOps->Close) S.outfOps->Close(S.outf);

Loading…
Cancel
Save