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;
|
||||
|
||||
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);
|
||||
delete fp;
|
||||
|
||||
|
@ -151,8 +154,11 @@ void UpdateReplayDialog(HWND hwndDlg)
|
|||
{
|
||||
MOVIE_INFO info;
|
||||
|
||||
FCEUFILE* fp = FCEU_fopen(fn,0,"rb",0);
|
||||
fp->stream = fp->stream->memwrap();
|
||||
FCEUFILE *fp = FCEU_fopen(fn,0,"rb",0);
|
||||
EMUFILE *tmp = fp->stream->memwrap();
|
||||
if (tmp != fp->stream)
|
||||
delete fp->stream;
|
||||
fp->stream = tmp;
|
||||
bool isarchive = FCEU_isFileInArchive(fn);
|
||||
bool ismovie = FCEUI_MovieGetInfo(fp, info, false);
|
||||
delete fp;
|
||||
|
|
|
@ -86,6 +86,7 @@ void EMUFILE_FILE::truncate(s32 length)
|
|||
#else
|
||||
ftruncate(fileno(fp),length);
|
||||
#endif
|
||||
// this is probably wrong if mode is "wb"
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//try to read a zip file
|
||||
{
|
||||
fceufp = TryUnzip(fileToOpen);
|
||||
|
|
Loading…
Reference in New Issue