Fix: Metal null buffer initialization

Buffer wasn't actually initialized and read out of bounds.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/106807
This commit is contained in:
Jason Fielder
2023-04-14 07:59:45 +02:00
committed by Jeroen Bakker
parent 2745cacd95
commit 26dc9f90d2

View File

@@ -497,7 +497,7 @@ id<MTLBuffer> MTLContext::get_null_buffer()
null_buffer_ = [this->device newBufferWithLength:null_buffer_size
options:MTLResourceStorageModeManaged];
[null_buffer_ retain];
uint32_t *null_data = (uint32_t *)calloc(0, null_buffer_size);
uint32_t *null_data = (uint32_t *)calloc(1, null_buffer_size);
memcpy([null_buffer_ contents], null_data, null_buffer_size);
[null_buffer_ didModifyRange:NSMakeRange(0, null_buffer_size)];
free(null_data);