Pull fix for heap corruption warning due to freeing new[]'ed memory with free() from Kitty Barnett / Catznip viewer

Ansariel 2013-03-23 21:43:50 +01:00
parent 1701b7bdc5
commit eadca62857
3 changed files with 25 additions and 5 deletions

View File

@ -396,7 +396,10 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
}
else
{
res = validate(data, file_size);
// [SL:KB] - Patch: Viewer-ImageBaseHeapCorruption | Checked: 2012-08-12 (Catznip-3.3)
res = validate(data, file_size, false);
// [/SL:KB]
// res = validate(data, file_size);
}
}
@ -409,12 +412,21 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
}
BOOL LLImageJ2C::validate(U8 *data, U32 file_size)
//BOOL LLImageJ2C::validate(U8 *data, U32 file_size)
// [SL:KB] - Patch: Viewer-ImageBaseHeapCorruption | Checked: 2012-08-12 (Catznip-3.3)
BOOL LLImageJ2C::validate(U8 *data, U32 file_size, bool copy_data)
// [/SL:KB]
{
resetLastError();
setData(data, file_size);
// [SL:KB] - Patch: Viewer-ImageBaseHeapCorruption | Checked: 2012-08-12 (Catznip-3.3)
if (!copy_data)
setData(data, file_size);
else
copyData(data, file_size);
// [/SL:KB]
// setData(data, file_size);
BOOL res = updateData();
if ( res )

View File

@ -65,7 +65,10 @@ public:
// Encode with comment text
BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0);
BOOL validate(U8 *data, U32 file_size);
// BOOL validate(U8 *data, U32 file_size);
// [SL:KB] - Patch: Viewer-ImageBaseHeapCorruption | Checked: 2012-08-12 (Catznip-3.3)
BOOL validate(U8 *data, U32 file_size, bool copy_data);
// [/SL:KB]
BOOL loadAndValidate(const std::string &filename);
// Encode accessors

View File

@ -422,7 +422,12 @@ void LLViewerTexLayerSetBuffer::doUpload()
file.read(data, file_size);
if (data)
{
valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'
// [SL:KB] - Patch: Viewer-ImageBaseHeapCorruption | Checked: 2012-08-12 (Catznip-3.3)
// Image data needs copying since 'data' was allocated with new[] and LLImageBase wants malloc or pool allocated memory
valid = integrity_test->validate(data, file_size, true);
delete[] data;
// [/SL:KB]
// valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'
}
else
{