Skip to content

Commit 6464a5e

Browse files
committed
Fix validation and pointer arithmetics
1 parent 1091ce1 commit 6464a5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

binding/Binding/SKVertices.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
5353
if (colors != null && positions.Length != colors.Length)
5454
throw new ArgumentException ("The number of colors must match the number of vertices.", nameof (colors));
5555

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

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

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

6565
if (indexOffset + indexCount >= indices.Length)
@@ -69,7 +69,7 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
6969
fixed (SKPoint* t = texs)
7070
fixed (SKColor* c = colors)
7171
fixed (UInt16* i = indices) {
72-
return GetObject (SkiaApi.sk_vertices_make_copy (vmode, vertexCount, p + vertexOffset, t + vertexOffset, (uint*)c + vertexOffset, indexCount, i + indexOffset));
72+
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)));
7373
}
7474
}
7575

0 commit comments

Comments
 (0)