Fixed crash when saving as a monochrome TIFF image with incomplete options set.
When setting only wxIMAGE_OPTION_TIFF_BITSPERSAMPLE to 1 the used samples per pixel (wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL) would still be set to 3. This is invalid and confuses libtiff, resulting in a crash ("possible heap corruption" during _TIFFfree using WinXP+MSVC8). Set the used samples per pixel to 1 explicitly in cases where only bits per sample is set to 1. Added a unit test to check for this problem (and verify the bits per sample from the saved image is indeed 1). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,6 +73,7 @@ private:
|
||||
CPPUNIT_TEST( CompareLoadedImage );
|
||||
CPPUNIT_TEST( CompareSavedImage );
|
||||
CPPUNIT_TEST( SavePNG );
|
||||
CPPUNIT_TEST( SaveTIFF );
|
||||
CPPUNIT_TEST( SaveAnimatedGIF );
|
||||
CPPUNIT_TEST( ReadCorruptedTGA );
|
||||
CPPUNIT_TEST( GIFComment );
|
||||
@@ -87,6 +88,7 @@ private:
|
||||
void CompareLoadedImage();
|
||||
void CompareSavedImage();
|
||||
void SavePNG();
|
||||
void SaveTIFF();
|
||||
void SaveAnimatedGIF();
|
||||
void ReadCorruptedTGA();
|
||||
void GIFComment();
|
||||
@@ -1088,6 +1090,33 @@ void ImageTestCase::SavePNG()
|
||||
|
||||
}
|
||||
|
||||
static void TestTIFFImage(const wxString& option, int value)
|
||||
{
|
||||
wxImage image("horse.png");
|
||||
|
||||
wxMemoryOutputStream memOut;
|
||||
image.SetOption(option, value);
|
||||
|
||||
CPPUNIT_ASSERT(image.SaveFile(memOut, wxBITMAP_TYPE_TIF));
|
||||
|
||||
wxMemoryInputStream memIn(memOut);
|
||||
CPPUNIT_ASSERT(memIn.IsOk());
|
||||
|
||||
wxImage savedImage(memIn);
|
||||
CPPUNIT_ASSERT(savedImage.IsOk());
|
||||
|
||||
WX_ASSERT_EQUAL_MESSAGE(("While checking for option %s", option),
|
||||
true, savedImage.HasOption(option));
|
||||
|
||||
WX_ASSERT_EQUAL_MESSAGE(("While testing for %s", option),
|
||||
value, savedImage.GetOptionInt(option));
|
||||
}
|
||||
|
||||
void ImageTestCase::SaveTIFF()
|
||||
{
|
||||
TestTIFFImage(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1);
|
||||
}
|
||||
|
||||
void ImageTestCase::SaveAnimatedGIF()
|
||||
{
|
||||
#if wxUSE_PALETTE
|
||||
|
Reference in New Issue
Block a user