From 6513fcf2ca073aadd6dc03015ecccfe1064a13b3 Mon Sep 17 00:00:00 2001 From: James Crook Date: Tue, 25 Jul 2017 20:48:38 +0100 Subject: [PATCH] Possible fix for Mac library issue. Fix off by one error in size. Git-bisect indicated a problem (on Mac only) caused by a change in an image file. It's possible that this is an error in code that we have 'got away with' until now. We always have an extra zero on the end of the image data and included it in the count of the size of stream to unpack. For a particular image this may have triggered a memory corruption problem. --- src/Theme.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Theme.cpp b/src/Theme.cpp index 131117c55..4555b24d9 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -985,7 +985,9 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound) pImage = HiContrastImageCacheAsData; break; } - + // The image size includes a rogue '0' on the end, because the array ends in a ','. + ImageSize--; + //wxLogDebug("Reading ImageCache %p size %i", pImage, ImageSize ); wxMemoryInputStream InternalStream( pImage, ImageSize ); if( !ImageCache.LoadFile( InternalStream, wxBITMAP_TYPE_PNG )) @@ -997,6 +999,7 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound) wxMessageBox(_("Audacity could not read its default theme.\nPlease report the problem.")); return false; } + //wxLogDebug("Read %i by %i", ImageCache.GetWidth(), ImageCache.GetHeight() ); } // Resize a large image down.