From c0d1efac279e2834f4cbd081e34b4349ea6542c0 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Tue, 17 Sep 2013 21:19:28 +0200 Subject: [PATCH] Fixed google code Issue 232 --- Recast/Source/RecastMesh.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Recast/Source/RecastMesh.cpp b/Recast/Source/RecastMesh.cpp index 13aad2a..23a4660 100644 --- a/Recast/Source/RecastMesh.cpp +++ b/Recast/Source/RecastMesh.cpp @@ -1105,7 +1105,9 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe unsigned short* pa = &polys[bestPa*nvp]; unsigned short* pb = &polys[bestPb*nvp]; mergePolys(pa, pb, bestEa, bestEb, tmpPoly, nvp); - memcpy(pb, &polys[(npolys-1)*nvp], sizeof(unsigned short)*nvp); + unsigned short* lastPoly = &polys[(npolys-1)*nvp]; + if (pb != lastPoly) + memcpy(pb, lastPoly, sizeof(unsigned short)*nvp); npolys--; } else