[Bf-blender-cvs] [599e560] blender-v2.78-release: Cycles: Fix overflow caused by wrong size calculation in Mesh::add_undisplaced

Mai Lavelle noreply at git.blender.org
Mon Sep 26 10:54:15 CEST 2016


Commit: 599e560a68c205788d30091284c0bb4d1588708c
Author: Mai Lavelle
Date:   Thu Sep 22 17:34:14 2016 -0400
Branches: blender-v2.78-release
https://developer.blender.org/rB599e560a68c205788d30091284c0bb4d1588708c

Cycles: Fix overflow caused by wrong size calculation in Mesh::add_undisplaced

===================================================================

M	intern/cycles/render/mesh.cpp

===================================================================

diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 2d297c3..3eff35b 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -601,6 +601,12 @@ void Mesh::add_undisplaced()
 
 	/* copy verts */
 	size_t size = attr->buffer_size(this, (subdivision_type == SUBDIVISION_NONE) ? ATTR_PRIM_TRIANGLE : ATTR_PRIM_SUBD);
+
+	/* Center points for ngons aren't stored in Mesh::verts but are included in size since they will be
+	 * calculated later, we subtract them from size here so we don't have an overflow while copying.
+	 */
+	size -= num_ngons * attr->data_sizeof();
+
 	if(size) {
 		memcpy(data, verts.data(), size);
 	}




More information about the Bf-blender-cvs mailing list