Skip to content

Commit

Permalink
Ensure nothing is preserved if previously allocated
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed May 22, 2016
1 parent 0300f59 commit d83f70a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ImageProcessorCore/ImageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ public void SetPixels(int width, int height, float[] pixels)
this.Width = width;
this.Height = height;

// Ensure nothing is preserved if previously allocated.
if (this.pixelsHandle.IsAllocated)
{
this.pixelsArray = null;
this.pixelsHandle.Free();
this.pixelsBase = null;
}

this.pixelsArray = pixels;
this.pixelsHandle = GCHandle.Alloc(this.pixelsArray, GCHandleType.Pinned);
this.pixelsBase = (float*)this.pixelsHandle.AddrOfPinnedObject().ToPointer();
Expand Down

0 comments on commit d83f70a

Please sign in to comment.