add return in case failing to create the file

Even the file is create in 'usr_path', it is better and more safely to check whether the file is created successfully.
The check against null pointer could protect the program from deference a null pointer.
This commit is contained in:
360 CodeSafe
2018-09-20 11:04:28 +08:00
committed by GitHub
parent f34963819b
commit 55bb707ef5

View File

@@ -578,14 +578,17 @@ void dumpregs(int force)
(void)plat_chdir(usr_path);
nopageerrors=1;
f=fopen("ram.dmp","wb");
if (!f) return;
fwrite(ram,mem_size*1024,1,f);
fclose(f);
pclog("Dumping rram.dmp\n");
f=fopen("rram.dmp","wb");
if (!f) return;
for (c=0;c<0x1000000;c++) putc(readmemb(c),f);
fclose(f);
pclog("Dumping rram4.dmp\n");
f=fopen("rram4.dmp","wb");
if (!f) return;
for (c=0;c<0x0050000;c++)
{
cpu_state.abrt = 0;