From e90ba47a13b2d77e05da13d2d260aac2e86a6f19 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Wed, 4 Apr 2018 13:32:23 -0700 Subject: [PATCH] [NoCopyRendering] In non-VM case, use calloc to get a zerod buffer. (#869) --- Source/ASCGImageBuffer.h | 1 + Source/ASCGImageBuffer.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/ASCGImageBuffer.h b/Source/ASCGImageBuffer.h index 47d4b8d306..88f1fd9c3e 100644 --- a/Source/ASCGImageBuffer.h +++ b/Source/ASCGImageBuffer.h @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN AS_SUBCLASSING_RESTRICTED @interface ASCGImageBuffer : NSObject +/// Init a zero-filled buffer with the given length. - (instancetype)initWithLength:(NSUInteger)length; @property (readonly) void *mutableBytes NS_RETURNS_INNER_POINTER; diff --git a/Source/ASCGImageBuffer.m b/Source/ASCGImageBuffer.m index 215dbc696b..8b236f65c6 100644 --- a/Source/ASCGImageBuffer.m +++ b/Source/ASCGImageBuffer.m @@ -47,7 +47,7 @@ // Check the VM flag again because we may have failed above. if (!_isVM) { - _mutableBytes = malloc(length); + _mutableBytes = calloc(1, length); } } return self;