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

This commit is contained in:
Mai Lavelle 2016-09-22 17:34:14 -04:00 committed by Sergey Sharybin
parent daa1487425
commit 599e560a68
1 changed files with 6 additions and 0 deletions

View File

@ -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);
}