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 6464a5e
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 @@ -53,13 +53,13 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
if (colors != null && positions.Length != colors.Length)
throw new ArgumentException ("The number of colors must match the number of vertices.", nameof (colors));

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

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

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

if (indexOffset + indexCount >= indices.Length)
Expand All @@ -69,7 +69,7 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
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 6464a5e

Please sign in to comment.