mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
(svn r22062) -Fix: memory leak when saving fails mid-way
This commit is contained in:
parent
296af35741
commit
7de823b1bd
@ -2012,6 +2012,12 @@ struct ZlibSaveFilter : SaveFilter {
|
|||||||
if (deflateInit(&this->z, compression_level) != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
if (deflateInit(&this->z, compression_level) != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Clean up what we allocated. */
|
||||||
|
~ZlibSaveFilter()
|
||||||
|
{
|
||||||
|
deflateEnd(&this->z);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper loop for writing the data.
|
* Helper loop for writing the data.
|
||||||
* @param p The bytes to write.
|
* @param p The bytes to write.
|
||||||
@ -2056,7 +2062,6 @@ struct ZlibSaveFilter : SaveFilter {
|
|||||||
{
|
{
|
||||||
this->WriteLoop(NULL, 0, Z_FINISH);
|
this->WriteLoop(NULL, 0, Z_FINISH);
|
||||||
this->chain->Finish();
|
this->chain->Finish();
|
||||||
deflateEnd(&this->z);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2134,6 +2139,12 @@ struct LZMASaveFilter : SaveFilter {
|
|||||||
if (lzma_easy_encoder(&this->lzma, compression_level, LZMA_CHECK_CRC32) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
if (lzma_easy_encoder(&this->lzma, compression_level, LZMA_CHECK_CRC32) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Clean up what we allocated. */
|
||||||
|
~LZMASaveFilter()
|
||||||
|
{
|
||||||
|
lzma_end(&this->lzma);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper loop for writing the data.
|
* Helper loop for writing the data.
|
||||||
* @param p The bytes to write.
|
* @param p The bytes to write.
|
||||||
@ -2170,7 +2181,6 @@ struct LZMASaveFilter : SaveFilter {
|
|||||||
{
|
{
|
||||||
this->WriteLoop(NULL, 0, LZMA_FINISH);
|
this->WriteLoop(NULL, 0, LZMA_FINISH);
|
||||||
this->chain->Finish();
|
this->chain->Finish();
|
||||||
lzma_end(&this->lzma);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user