calling fwrite() with a null pointer causes undefined behavior. avoid it.

This commit is contained in:
Axel Kohlmeyer
2021-09-25 10:18:55 -04:00
parent 530912a930
commit 53e773e438
5 changed files with 10 additions and 5 deletions

View File

@ -562,7 +562,8 @@ void DumpAtom::write_binary(int n, double *mybuf)
void DumpAtom::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
if (mybuf)
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */

View File

@ -233,7 +233,8 @@ void DumpCFG::write_data(int n, double *mybuf)
void DumpCFG::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
if (mybuf)
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */

View File

@ -1234,7 +1234,8 @@ void DumpCustom::write_binary(int n, double *mybuf)
void DumpCustom::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
if (mybuf)
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */

View File

@ -399,7 +399,8 @@ void DumpLocal::write_data(int n, double *mybuf)
void DumpLocal::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
if (mybuf)
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */

View File

@ -194,7 +194,8 @@ void DumpXYZ::write_data(int n, double *mybuf)
void DumpXYZ::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
if (mybuf)
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */