From 480f56e94d562dab1cfe3fa658607d317d5ea798 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Tue, 24 Jun 2014 09:30:59 +0300 Subject: [PATCH] Fixed memory allocation in detail mesh and memcpy in polymesh copy --- Recast/Source/RecastMesh.cpp | 2 +- Recast/Source/RecastMeshDetail.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Recast/Source/RecastMesh.cpp b/Recast/Source/RecastMesh.cpp index dffd450..e4f9c4b 100644 --- a/Recast/Source/RecastMesh.cpp +++ b/Recast/Source/RecastMesh.cpp @@ -1537,7 +1537,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst) ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.flags' (%d).", src.npolys); return false; } - memcpy(dst.flags, src.flags, sizeof(unsigned char)*src.npolys); + memcpy(dst.flags, src.flags, sizeof(unsigned short)*src.npolys); return true; } diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp index 431952f..10c8171 100644 --- a/Recast/Source/RecastMeshDetail.cpp +++ b/Recast/Source/RecastMeshDetail.cpp @@ -1217,7 +1217,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa return false; } dmesh.ntris = 0; - dmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char*)*tcap*4, RC_ALLOC_PERM); + dmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM); if (!dmesh.tris) { ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).", tcap*4);