mirror of
https://github.com/libretro/pcsx2.git
synced 2025-02-26 12:25:46 +00:00
common, GSnull, zzogl-pg, SPU2null: add more safety to some fclose functions. Avoid a bunch of double free and memory corruption.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3671 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
92dbee7e79
commit
112800cb98
@ -64,7 +64,10 @@ struct PluginLog
|
||||
|
||||
void Close()
|
||||
{
|
||||
if (LogFile) fclose(LogFile);
|
||||
if (LogFile) {
|
||||
fclose(LogFile);
|
||||
LogFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Write(const char *fmt, ...)
|
||||
@ -132,7 +135,10 @@ struct PluginConf
|
||||
|
||||
void Close()
|
||||
{
|
||||
fclose(ConfFile);
|
||||
if (ConfFile) {
|
||||
fclose(ConfFile);
|
||||
ConfFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ReadInt(const std::string& item, int defval)
|
||||
|
@ -136,7 +136,10 @@ EXPORT_C_(void) GSsetLogDir(const char* dir)
|
||||
s_strLogPath = (dir==NULL) ? "logs/" : dir;
|
||||
|
||||
// Reload the log file after updated the path
|
||||
if (gsLog != NULL) fclose(gsLog);
|
||||
if (gsLog) {
|
||||
fclose(gsLog);
|
||||
gsLog = NULL;
|
||||
}
|
||||
OpenLog();
|
||||
}
|
||||
|
||||
@ -156,7 +159,10 @@ EXPORT_C_(void) GSshutdown()
|
||||
GSCloseWindow();
|
||||
|
||||
#ifdef GS_LOG
|
||||
if (gsLog) fclose(gsLog);
|
||||
if (gsLog) {
|
||||
fclose(gsLog);
|
||||
gsLog = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,10 @@ EXPORT_C_(void) SPU2setLogDir(const char* dir)
|
||||
s_strLogPath = (dir==NULL) ? "logs/" : dir;
|
||||
|
||||
// Reload the log file after updated the path
|
||||
if (spu2Log) fclose(spu2Log);
|
||||
if(spu2Log) {
|
||||
fclose(spu2Log);
|
||||
spu2Log = NULL;
|
||||
}
|
||||
OpenLog();
|
||||
}
|
||||
|
||||
@ -209,7 +212,10 @@ EXPORT_C_(void) SPU2shutdown()
|
||||
free(spu2mem);
|
||||
spu2mem = NULL;
|
||||
#ifdef SPU2_LOG
|
||||
if (spu2Log) fclose(spu2Log);
|
||||
if(spu2Log) {
|
||||
fclose(spu2Log);
|
||||
spu2Log = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,10 @@ bool Open()
|
||||
|
||||
void Close()
|
||||
{
|
||||
if (gsLog != NULL) fclose(gsLog);
|
||||
if (gsLog != NULL) {
|
||||
fclose(gsLog);
|
||||
gsLog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SetDir(const char* dir)
|
||||
@ -62,7 +65,7 @@ void SetDir(const char* dir)
|
||||
s_strLogPath = (dir==NULL) ? "logs/" : dir;
|
||||
|
||||
// Reload the log file after updated the path
|
||||
if (gsLog != NULL) fclose(gsLog);
|
||||
Close();
|
||||
Open();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user