Author: fredkiefer
Date: Fri Jan 23 18:16:08 2015
New Revision: 38301
URL: http://svn.gna.org/viewcvs/gnustep?rev=38301&view=rev
Log:
* Source/NSBitmapImageRep.m (-copyWithZone): Changed the call
from -copyWithZone: to -mutableCopyWithZone:.
* Tests/gui/NSBitmapImageRep/testcopy.m: Test for this change
Patch by Josh Freeman <tedge>.
Added:
libs/gui/trunk/Tests/gui/NSBitmapImageRep/
libs/gui/trunk/Tests/gui/NSBitmapImageRep/TestInfo
libs/gui/trunk/Tests/gui/NSBitmapImageRep/testcopy.m
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/NSBitmapImageRep.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=38301&r1=38300&r2=38301&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Fri Jan 23 18:16:08 2015
@@ -1,3 +1,10 @@
+2015-01-23 Fred Kiefer <[email protected]>
+
+ * Source/NSBitmapImageRep.m (-copyWithZone): Changed the call from
+ -copyWithZone: to -mutableCopyWithZone:.
+ * Tests/gui/NSBitmapImageRep/testcopy.m: Test for this change
+ Patch by Josh Freeman <tedge>.
+
2015-01-23 Fred Kiefer <[email protected]>
* Source/tiff.m: Correct check for old libtiff version based on
Modified: libs/gui/trunk/Source/NSBitmapImageRep.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSBitmapImageRep.m?rev=38301&r1=38300&r2=38301&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSBitmapImageRep.m (original)
+++ libs/gui/trunk/Source/NSBitmapImageRep.m Fri Jan 23 18:16:08 2015
@@ -1762,7 +1762,7 @@
copy = (NSBitmapImageRep*)[super copyWithZone: zone];
copy->_properties = [_properties copyWithZone: zone];
- copy->_imageData = [_imageData copyWithZone: zone];
+ copy->_imageData = [_imageData mutableCopyWithZone: zone];
copy->_imagePlanes = NSZoneMalloc(zone, sizeof(unsigned char*) * MAX_PLANES);
if (_imageData == nil)
{
Added: libs/gui/trunk/Tests/gui/NSBitmapImageRep/TestInfo
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Tests/gui/NSBitmapImageRep/TestInfo?rev=38301&view=auto
==============================================================================
(empty)
Added: libs/gui/trunk/Tests/gui/NSBitmapImageRep/testcopy.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Tests/gui/NSBitmapImageRep/testcopy.m?rev=38301&view=auto
==============================================================================
--- libs/gui/trunk/Tests/gui/NSBitmapImageRep/testcopy.m (added)
+++ libs/gui/trunk/Tests/gui/NSBitmapImageRep/testcopy.m Fri Jan 23
18:16:08 2015
@@ -0,0 +1,37 @@
+#import "ObjectTesting.h"
+#import <Foundation/NSArray.h>
+#import <Foundation/NSAutoreleasePool.h>
+#import <AppKit/NSApplication.h>
+#import <AppKit/NSBitmapImageRep.h>
+#import <AppKit/NSGraphics.h>
+
+int main()
+{
+ NSAutoreleasePool *arp = [NSAutoreleasePool new];
+ NSBitmapImageRep *origBitmap, *copy1Bitmap, *copy2Bitmap;
+
+ origBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
+ pixelsWide: 4
+ pixelsHigh: 4
+ bitsPerSample: 8
+ samplesPerPixel: 4
+ hasAlpha: YES
+ isPlanar: NO
+ colorSpaceName:
NSCalibratedRGBColorSpace
+ bytesPerRow: 0
+ bitsPerPixel: 0];
+
+ copy1Bitmap = [origBitmap copy];
+
+ // Copying immutable NSData reuses the data pointer instead of allocating
new memory, so
+ // copying a bitmap with immutable _imageData causes both bitmaps to point
to the same memory;
+ // Writing to either copy's pixels will overwrite both, corrupting the image
data
+
+ copy2Bitmap = [copy1Bitmap copy];
+
+ pass([copy1Bitmap bitmapData] != [copy2Bitmap bitmapData],
+ "Copied bitmaps have a different image data pointer - could cause image
data corruption.");
+
+ [arp release];
+ return 0;
+}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs