Skip to content

Commit

Permalink
Return an empty surface in case the allocation has failed (resolves #…
Browse files Browse the repository at this point in the history
  • Loading branch information
richirisu committed Jun 6, 2021
1 parent 2019706 commit dbcd625
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public SKSurface CreateSurface(CGRect contentsBounds, nfloat scale, out SKImageI
if (bitmapData == null)
{
bitmapData = NSMutableData.FromLength(info.BytesSize);

// in case allocation has failed
if (bitmapData == null) {
info.Width = info.Height = 0;
return null;
}

dataProvider = new CGDataProvider(bitmapData.MutableBytes, info.BytesSize, Dummy);

void Dummy(IntPtr data)
Expand Down

0 comments on commit dbcd625

Please sign in to comment.