Commit: 1cb7267a9f9f1695f296bdbb618ec117f483484c
Author: Ray Molenkamp
Date:   Fri Aug 28 09:46:57 2020 -0600
Branches: master
https://developer.blender.org/rB1cb7267a9f9f1695f296bdbb618ec117f483484c

Cleanup: Fix build error with msvc

`ssize_t` is not a standardized type (it's a posix type)
given the line in question here is calculating the size
of a memory allocation there's no logical way this
should ever be negative.

I do not know this code too well and was unsure if
`mdverts->totweight` could ever be < 0, so I protected
it with a clamp, just in case.

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

M       source/blender/blenkernel/intern/deform.c

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

diff --git a/source/blender/blenkernel/intern/deform.c 
b/source/blender/blenkernel/intern/deform.c
index 4f5a2740ca6..ea5e4ec6532 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -1557,7 +1557,7 @@ void BKE_defvert_blend_read(BlendDataReader *reader, int 
count, MDeformVert *mdv
     /*convert to vgroup allocation system*/
     MDeformWeight *dw;
     if (mdverts->dw && (dw = BLO_read_get_new_data_address(reader, 
mdverts->dw))) {
-      const ssize_t dw_len = mdverts->totweight * sizeof(MDeformWeight);
+      const size_t dw_len = MAX2(mdverts->totweight, 0) * 
sizeof(MDeformWeight);
       void *dw_tmp = MEM_mallocN(dw_len, __func__);
       memcpy(dw_tmp, dw, dw_len);
       mdverts->dw = dw_tmp;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to