Fix crash when file cannot be opened for writing.
This commit is contained in:
parent
eae07f1977
commit
cf92bfaeee
1 changed files with 8 additions and 0 deletions
|
@ -494,6 +494,10 @@ main (int argc, const char *argv[])
|
||||||
printf ("Writing data to file: %s ...", argv[3]);
|
printf ("Writing data to file: %s ...", argv[3]);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
pfDump = fopen (argv[3], "wb");
|
pfDump = fopen (argv[3], "wb");
|
||||||
|
if (pfDump == NULL) {
|
||||||
|
printf ("Could not open dump file: %s\n", argv[3]);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
if (fwrite (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
|
if (fwrite (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
|
||||||
printf ("\nCould not write to file: %s\n", argv[3]);
|
printf ("\nCould not write to file: %s\n", argv[3]);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
@ -536,6 +540,10 @@ main (int argc, const char *argv[])
|
||||||
|
|
||||||
printf ("Writing data to file: %s\n", pcPayload);
|
printf ("Writing data to file: %s\n", pcPayload);
|
||||||
pfPayload = fopen (pcPayload, "wb");
|
pfPayload = fopen (pcPayload, "wb");
|
||||||
|
if (pfPayload == NULL) {
|
||||||
|
printf ("Could not open file %s for writting.\n", pcPayload);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
if (fwrite (abPayload, 1, sizeof (abPayload), pfPayload) != sizeof (abPayload)) {
|
if (fwrite (abPayload, 1, sizeof (abPayload), pfPayload) != sizeof (abPayload)) {
|
||||||
printf ("Could not write to file: %s\n", pcPayload);
|
printf ("Could not write to file: %s\n", pcPayload);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue