mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-10 19:09:45 +01:00
Unconditionally free and zero in binaryBlob::clear()
The function previously conditionally freed a m_memblocks pointer if its corresponding m_headers was valid. This makes me slightly worried about the possibility that memory would be allocated, but the header would still be marked as invalid. I don't see how that could happen, but it's better to be safe than sorry. SDL_free() does a guaranteed NULL pointer check (like most SDL functions), so it's okay to pass NULL pointers to it. Just to be sure, I'm also zeroing m_memblocks and m_headers after freeing everything in the function.
This commit is contained in:
parent
47df6c9d66
commit
bd97378862
1 changed files with 3 additions and 5 deletions
|
@ -138,13 +138,11 @@ bool binaryBlob::unPackBinary(const char* name)
|
||||||
void binaryBlob::clear()
|
void binaryBlob::clear()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
||||||
{
|
|
||||||
if (m_headers[i].valid)
|
|
||||||
{
|
{
|
||||||
SDL_free(m_memblocks[i]);
|
SDL_free(m_memblocks[i]);
|
||||||
m_headers[i].valid = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
SDL_zeroa(m_memblocks);
|
||||||
|
SDL_zeroa(m_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int binaryBlob::getIndex(const char* _name)
|
int binaryBlob::getIndex(const char* _name)
|
||||||
|
|
Loading…
Reference in a new issue