Fixes for some file handles and memory leaks.
This commit is contained in:
parent
5a1e6c552a
commit
2d81852e81
|
@ -126,7 +126,10 @@ void UpdateReplayCommentsSubs(const char * fname) {
|
||||||
MOVIE_INFO info;
|
MOVIE_INFO info;
|
||||||
|
|
||||||
FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0);
|
FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0);
|
||||||
fp->stream = fp->stream->memwrap();
|
EMUFILE *tmp = fp->stream->memwrap();
|
||||||
|
if (tmp != fp->stream)
|
||||||
|
delete fp->stream;
|
||||||
|
fp->stream = tmp;
|
||||||
bool scanok = FCEUI_MovieGetInfo(fp, info, true);
|
bool scanok = FCEUI_MovieGetInfo(fp, info, true);
|
||||||
delete fp;
|
delete fp;
|
||||||
|
|
||||||
|
@ -151,8 +154,11 @@ void UpdateReplayDialog(HWND hwndDlg)
|
||||||
{
|
{
|
||||||
MOVIE_INFO info;
|
MOVIE_INFO info;
|
||||||
|
|
||||||
FCEUFILE* fp = FCEU_fopen(fn,0,"rb",0);
|
FCEUFILE *fp = FCEU_fopen(fn,0,"rb",0);
|
||||||
fp->stream = fp->stream->memwrap();
|
EMUFILE *tmp = fp->stream->memwrap();
|
||||||
|
if (tmp != fp->stream)
|
||||||
|
delete fp->stream;
|
||||||
|
fp->stream = tmp;
|
||||||
bool isarchive = FCEU_isFileInArchive(fn);
|
bool isarchive = FCEU_isFileInArchive(fn);
|
||||||
bool ismovie = FCEUI_MovieGetInfo(fp, info, false);
|
bool ismovie = FCEUI_MovieGetInfo(fp, info, false);
|
||||||
delete fp;
|
delete fp;
|
||||||
|
|
|
@ -86,6 +86,7 @@ void EMUFILE_FILE::truncate(s32 length)
|
||||||
#else
|
#else
|
||||||
ftruncate(fileno(fp),length);
|
ftruncate(fileno(fp),length);
|
||||||
#endif
|
#endif
|
||||||
|
// this is probably wrong if mode is "wb"
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
open(fname.c_str(),mode);
|
open(fname.c_str(),mode);
|
||||||
|
|
|
@ -284,11 +284,16 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
|
||||||
{
|
{
|
||||||
//if the archive contained no files, try to open it the old fashioned way
|
//if the archive contained no files, try to open it the old fashioned way
|
||||||
EMUFILE_FILE* fp = FCEUD_UTF8_fstream(fileToOpen,mode);
|
EMUFILE_FILE* fp = FCEUD_UTF8_fstream(fileToOpen,mode);
|
||||||
if(!fp || (fp->get_fp() == NULL))
|
if(!fp)
|
||||||
|
return 0;
|
||||||
|
if (fp->get_fp() == NULL)
|
||||||
{
|
{
|
||||||
|
//fp is new'ed so it has to be deleted
|
||||||
|
delete fp;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//try to read a zip file
|
//try to read a zip file
|
||||||
{
|
{
|
||||||
fceufp = TryUnzip(fileToOpen);
|
fceufp = TryUnzip(fileToOpen);
|
||||||
|
|
Loading…
Reference in New Issue