зеркало из https://github.com/mozilla/gecko-dev.git
Bug 990787, part 6 - If a Compressor object is never successfully initialized, don't call deflateEnd in the destructor. r=luke.
--HG-- extra : rebase_source : 3ac0ef84110f119d7b5f89742434c7db9619df29
This commit is contained in:
Родитель
2a14487768
Коммит
6dafb8ceb0
|
@ -26,7 +26,8 @@ zlib_free(void *cx, void *addr)
|
|||
Compressor::Compressor(const unsigned char *inp, size_t inplen)
|
||||
: inp(inp),
|
||||
inplen(inplen),
|
||||
outbytes(0)
|
||||
outbytes(0),
|
||||
initialized(false)
|
||||
{
|
||||
JS_ASSERT(inplen > 0);
|
||||
zs.opaque = nullptr;
|
||||
|
@ -41,11 +42,13 @@ Compressor::Compressor(const unsigned char *inp, size_t inplen)
|
|||
|
||||
Compressor::~Compressor()
|
||||
{
|
||||
int ret = deflateEnd(&zs);
|
||||
if (ret != Z_OK) {
|
||||
// If we finished early, we can get a Z_DATA_ERROR.
|
||||
JS_ASSERT(ret == Z_DATA_ERROR);
|
||||
JS_ASSERT(uInt(zs.next_in - inp) < inplen || !zs.avail_out);
|
||||
if (initialized) {
|
||||
int ret = deflateEnd(&zs);
|
||||
if (ret != Z_OK) {
|
||||
// If we finished early, we can get a Z_DATA_ERROR.
|
||||
JS_ASSERT(ret == Z_DATA_ERROR);
|
||||
JS_ASSERT(uInt(zs.next_in - inp) < inplen || !zs.avail_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +65,7 @@ Compressor::init()
|
|||
JS_ASSERT(ret == Z_MEM_ERROR);
|
||||
return false;
|
||||
}
|
||||
initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class Compressor
|
|||
const unsigned char *inp;
|
||||
size_t inplen;
|
||||
size_t outbytes;
|
||||
bool initialized;
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
|
|
Загрузка…
Ссылка в новой задаче