From 9eaad6e14dbb4ebb029a0709c493d8053679c745 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Mon, 15 Jun 2020 21:58:13 -0400 Subject: [PATCH] Revolved Deallocating a deallocated pointer: buf warning in archive.cpp. --- src/drivers/win/archive.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/drivers/win/archive.cpp b/src/drivers/win/archive.cpp index 75bdfff7..7aa93f30 100644 --- a/src/drivers/win/archive.cpp +++ b/src/drivers/win/archive.cpp @@ -181,7 +181,7 @@ protected: public: explicit InStream() - : refCount(0) + : refCount(0), size(0) {} }; @@ -374,17 +374,21 @@ void initArchiveSystem() } } -static std::string wstringFromPROPVARIANT(BSTR bstr, bool& success) { +static std::string wstringFromPROPVARIANT(BSTR bstr, bool& success) +{ + std::string strret; std::wstring tempfname = bstr; int buflen = tempfname.size()*2; char* buf = new char[buflen]; int ret = WideCharToMultiByte(CP_ACP,0,tempfname.c_str(),tempfname.size(),buf,buflen,0,0); - if(ret == 0) { + if (ret == 0) + { delete[] buf; success = false; + return strret; } buf[ret] = 0; - std::string strret = buf; + strret = buf; delete[] buf; success = true; return strret; @@ -594,4 +598,4 @@ FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::str FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename) { return FCEUD_OpenArchive(asr, fname, innerFilename, -1); -} \ No newline at end of file +}