calling fwrite() with a null pointer causes undefined behavior. avoid it.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user