unchecked argv[idx] access

This commit is contained in:
niXman 2017-04-26 13:04:04 +03:00
parent 230d7acc7d
commit 65e2cda7aa
3 changed files with 6 additions and 3 deletions

View File

@ -116,7 +116,6 @@ static char* createOutFilename_orDie(const char* filename)
int main(int argc, const char** argv)
{
const char* const exeName = argv[0];
const char* const inFilename = argv[1];
if (argc!=2) {
printf("wrong arguments\n");
@ -125,6 +124,8 @@ int main(int argc, const char** argv)
return 1;
}
const char* const inFilename = argv[1];
char* const outFilename = createOutFilename_orDie(inFilename);
compress_orDie(inFilename, outFilename);
free(outFilename);

View File

@ -112,7 +112,6 @@ static const char* createOutFilename_orDie(const char* filename)
int main(int argc, const char** argv)
{
const char* const exeName = argv[0];
const char* const inFilename = argv[1];
if (argc!=2) {
printf("wrong arguments\n");
@ -121,6 +120,8 @@ int main(int argc, const char** argv)
return 1;
}
const char* const inFilename = argv[1];
const char* const outFilename = createOutFilename_orDie(inFilename);
compressFile_orDie(inFilename, outFilename, 1);

View File

@ -99,7 +99,6 @@ static void decompressFile_orDie(const char* fname)
int main(int argc, const char** argv)
{
const char* const exeName = argv[0];
const char* const inFilename = argv[1];
if (argc!=2) {
fprintf(stderr, "wrong arguments\n");
@ -108,6 +107,8 @@ int main(int argc, const char** argv)
return 1;
}
const char* const inFilename = argv[1];
decompressFile_orDie(inFilename);
return 0;
}