Skip to content

Commit

Permalink
Fix validation and pointer arithmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
seclerp committed Mar 29, 2023
1 parent 1091ce1 commit 684c465
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions binding/Binding/SKVertices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
if (vertexOffset >= positions.Length)
throw new ArgumentException ("The vertex offset should be in bounds of vertex array.", nameof (vertexOffset));

if (vertexOffset + vertexCount >= positions.Length)
if (vertexOffset + vertexCount > positions.Length)
throw new ArgumentException ("The vertex count should be in bounds of vertex array.", nameof (vertexOffset));

if (indexOffset >= indices.Length)
throw new ArgumentException ("The index offset should be in bounds of index array.", nameof (vertexOffset));

if (indexOffset + indexCount >= indices.Length)
if (indexOffset + indexCount > indices.Length)
throw new ArgumentException ("The vertex count should be in bounds of vertex array.", nameof (vertexOffset));

fixed (SKPoint* p = positions)
fixed (SKPoint* t = texs)
fixed (SKColor* c = colors)
fixed (UInt16* i = indices) {
return GetObject (SkiaApi.sk_vertices_make_copy (vmode, vertexCount, p + vertexOffset, t + vertexOffset, (uint*)c + vertexOffset, indexCount, i + indexOffset));
return GetObject (SkiaApi.sk_vertices_make_copy (vmode, vertexCount, p + vertexOffset * sizeof(SKPoint), t + vertexOffset * sizeof(SKPoint), (uint*)c + vertexOffset * sizeof(uint), indexCount, i + indexOffset * sizeof(ushort)));
}
}

Expand Down

0 comments on commit 684c465

Please sign in to comment.