mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
fix some memleaks in DiscIO. Fix for issue 1238.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3936 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -114,10 +114,10 @@ bool IBannerLoader::CopyBeUnicodeToString( std::string& _rDestination, const u16
|
||||
_rDestination = pAnsiStrBuffer;
|
||||
returnCode = true;
|
||||
}
|
||||
delete pAnsiStrBuffer;
|
||||
delete[] pAnsiStrBuffer;
|
||||
}
|
||||
}
|
||||
delete buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -122,7 +122,7 @@ bool CBannerLoaderWii::GetBanner(u32* _pBannerImage)
|
||||
{
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
|
||||
u32 Buffer[192 * 64];
|
||||
u32* Buffer = new u32[192 * 64];
|
||||
decode5A3image(Buffer, (u16*)pBanner->m_BannerTexture, 192, 64);
|
||||
|
||||
// ugly scaling :) TODO: at least a 2x2 box filter, preferably a 3x3 gaussian :)
|
||||
@ -132,7 +132,9 @@ bool CBannerLoaderWii::GetBanner(u32* _pBannerImage)
|
||||
{
|
||||
_pBannerImage[y*96+x] = Buffer[(y*192*2) + (x*2)];
|
||||
}
|
||||
}
|
||||
}
|
||||
delete pBanner;
|
||||
delete[] Buffer;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
|
||||
offsets[i] = position;
|
||||
// u64 start = i * header.block_size;
|
||||
// u64 size = header.block_size;
|
||||
memset(in_buf, 0, header.block_size);
|
||||
std::fill(in_buf, in_buf + header.block_size, 0);
|
||||
fread(in_buf, header.block_size, 1, inf);
|
||||
z_stream z;
|
||||
memset(&z, 0, sizeof(z));
|
||||
|
@ -123,7 +123,7 @@ bool Scrub(const char* filename, CompressCB callback, void* arg)
|
||||
m_Disc = CreateVolumeFromFilename(filename);
|
||||
m_FileSize = m_Disc->GetSize();
|
||||
|
||||
u64 numClusters = m_FileSize / CLUSTER_SIZE;
|
||||
u32 numClusters = (u32)(m_FileSize / CLUSTER_SIZE);
|
||||
|
||||
// Warn if not DVD5 or DVD9 size
|
||||
if (numClusters != 0x23048 && numClusters != 0x46090)
|
||||
@ -158,7 +158,7 @@ bool Scrub(const char* filename, CompressCB callback, void* arg)
|
||||
|
||||
// Modify file, obeying the table of free blocks
|
||||
NOTICE_LOG(DISCIO, "Removing garbage data...go get some coffee :)");
|
||||
for (u64 i = 0; i < numClusters; i++)
|
||||
for (u32 i = 0; i < numClusters; i++)
|
||||
{
|
||||
u64 CurrentOffset = i * CLUSTER_SIZE;
|
||||
|
||||
@ -184,7 +184,7 @@ bool Scrub(const char* filename, CompressCB callback, void* arg)
|
||||
if (i % (numClusters / 1000) == 0)
|
||||
{
|
||||
char temp[512];
|
||||
sprintf(temp, "DiscScrubber: %llu/%llu (%s)", i, numClusters, m_FreeTable[i] ? "Free" : "Used");
|
||||
sprintf(temp, "DiscScrubber: %lu/%lu (%s)", i, numClusters, m_FreeTable[i] ? "Free" : "Used");
|
||||
callback(temp, (float)i / (float)numClusters, arg);
|
||||
}
|
||||
}
|
||||
@ -196,8 +196,8 @@ bool Scrub(const char* filename, CompressCB callback, void* arg)
|
||||
|
||||
cleanup:
|
||||
if (pFile) fclose(pFile);
|
||||
delete m_Sector1;
|
||||
delete m_FreeTable;
|
||||
delete[] m_Sector1;
|
||||
delete[] m_FreeTable;
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -241,10 +241,9 @@ bool MarkAsScrubbed(const char* filename)
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
bool success;
|
||||
u8 ScrubbedFlag[1] = {SCRUBBER_VERSION};
|
||||
fseek(f, 0x80, SEEK_SET);
|
||||
success |= fwrite(ScrubbedFlag, 1, 1, f) == 1;
|
||||
bool success = fwrite(ScrubbedFlag, 1, 1, f) == 1;
|
||||
fclose(f);
|
||||
return success;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace DiscIO
|
||||
fread(lpSector, 1, m_blocksize, file_);
|
||||
#endif
|
||||
memcpy(out_ptr, lpSector, m_blocksize);
|
||||
delete lpSector;
|
||||
delete[] lpSector;
|
||||
}
|
||||
|
||||
bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr)
|
||||
|
@ -39,7 +39,7 @@ struct SFileInfo
|
||||
|
||||
SFileInfo(const SFileInfo &rhs) : m_NameOffset(rhs.m_NameOffset),
|
||||
m_Offset(rhs.m_Offset), m_FileSize(rhs.m_FileSize) {
|
||||
strcpy(m_FullPath, rhs.m_FullPath);
|
||||
memcpy(m_FullPath, rhs.m_FullPath, strlen(rhs.m_FullPath));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -253,12 +253,12 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
|
||||
FILE* pFile = fopen(szFilename, "rb");
|
||||
if (pFile != NULL)
|
||||
{
|
||||
u64 Size = File::GetSize(szFilename);
|
||||
rContent.m_pData = new u8[(u32)Size];
|
||||
u64 ContentSize = File::GetSize(szFilename);
|
||||
rContent.m_pData = new u8[(u32)ContentSize];
|
||||
|
||||
_dbg_assert_msg_(BOOT, rContent.m_Size==Size, "TMDLoader: Filesize doesnt fit (%s %i)... prolly you have a bad dump", szFilename, i);
|
||||
_dbg_assert_msg_(BOOT, rContent.m_Size==ContentSize, "TMDLoader: Filesize doesnt fit (%s %i)... prolly you have a bad dump", szFilename, i);
|
||||
|
||||
fread(rContent.m_pData, (size_t)Size, 1, pFile);
|
||||
fread(rContent.m_pData, (size_t)ContentSize, 1, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
else
|
||||
|
@ -202,10 +202,8 @@ CISOProperties::~CISOProperties()
|
||||
{
|
||||
for (std::vector<WiiPartition>::const_iterator PartIter = WiiDisc.begin(); PartIter != WiiDisc.end(); ++PartIter)
|
||||
{
|
||||
delete PartIter->FileSystem;
|
||||
delete PartIter->FileSystem; // Also deletes the corresponding PartIter->Files
|
||||
delete PartIter->Partition;
|
||||
for (std::vector<const DiscIO::SFileInfo *>::const_iterator FileIter = PartIter->Files.begin(); FileIter != PartIter->Files.end(); ++FileIter)
|
||||
delete *FileIter;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1068,7 +1066,7 @@ bool CISOProperties::CopySJISToString( wxString& _rDestination, const char* _src
|
||||
}
|
||||
#endif
|
||||
}
|
||||
delete pUnicodeStrBuffer;
|
||||
delete[] pUnicodeStrBuffer;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
Reference in New Issue
Block a user