diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-03-14 21:16:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-03-14 21:16:54 +0300 |
commit | 56d7a612e38acf850e974063531865fd89ba9990 (patch) | |
tree | 02128022ca6b0840b381180c95a1fe2411fc151f /source/blender/blenkernel/intern/mesh.c | |
parent | fcdf2d694f29d9a5a2a4b0edb79db8904f8f2721 (diff) |
fixed a possible use of uninitialized orco coords if the mesh has more totverts then keyblock elements.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 3bfd605cf27..9155a5ee444 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1109,9 +1109,13 @@ float (*mesh_getRefKeyCos(Mesh *me, int *numVerts_r))[3] if(me->key && me->key->refkey) { if(numVerts_r) *numVerts_r= me->totvert; - cos= MEM_mallocN(sizeof(*cos)*me->totvert, "vertexcos1"); - + kb= me->key->refkey; + + /* prevent accessing invalid memory */ + if (me->totvert > kb->totelem) cos= MEM_callocN(sizeof(*cos)*me->totvert, "vertexcos1"); + else cos= MEM_mallocN(sizeof(*cos)*me->totvert, "vertexcos1"); + totvert= MIN2(kb->totelem, me->totvert); memcpy(cos, kb->data, sizeof(*cos)*totvert); |