From 8c7d9bbd064c605b756ebf4752eaefad25ee6f4f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 14 Apr 2011 09:28:34 -0700 Subject: EXP-663 : Fix memory leak introduced in precincts handling --- indra/llkdu/llimagej2ckdu.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 8d2ed8f8c4..5b2c045841 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -361,17 +361,23 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco } int discard = (discard_level != -1 ? discard_level : base.getRawDiscardLevel()); + // Apply loading restrictions mCodeStreamp->apply_input_restrictions( first_channel, max_channel_count, discard, 0, region_kdu); + + // Clean-up + if (region_kdu) + { + delete region_kdu; + region_kdu = NULL; + } + // Resize raw_image according to the image to be decoded kdu_dims dims; mCodeStreamp->get_dims(0,dims); S32 channels = base.getComponents() - first_channel; - if (channels > max_channel_count) - { - channels = max_channel_count; - } + channels = llmin(channels,max_channel_count); raw_image.resize(dims.size.x, dims.size.y, channels); + // llinfos << "Resizing raw_image to " << dims.size.x << ":" << dims.size.y << llendl; - // llinfos << "Resizing to " << dims.size.x << ":" << dims.size.y << llendl; if (!mTileIndicesp) { mTileIndicesp = new kdu_dims; -- cgit v1.2.3