diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-10-01 10:19:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-10-01 10:21:08 +0300 |
commit | e5117108aae8ae9a380b27b6402d2419ea8cebc7 (patch) | |
tree | 2251e00b0778df9d7de22944f5a13f3a4d75d7db /source/blender | |
parent | 22ec991e6b8f19da39ac27f988f1eaab3027b421 (diff) |
Fix potential memory leak baking
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/render/intern/source/bake_api.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c index 87cdd8767e0..77f6ab9cfc2 100644 --- a/source/blender/render/intern/source/bake_api.c +++ b/source/blender/render/intern/source/bake_api.c @@ -591,6 +591,18 @@ void RE_bake_pixels_populate( if (me->edit_btmesh) return; + if ((uv_layer == NULL) || (uv_layer[0] == '\0')) { + mloopuv = CustomData_get_layer(&me->ldata, CD_MLOOPUV); + } + else { + int uv_id = CustomData_get_named_layer(&me->ldata, CD_MLOOPUV, uv_layer); + mloopuv = CustomData_get_layer_n(&me->ldata, CD_MTFACE, uv_id); + } + + if (mloopuv == NULL) + return; + + bd.pixel_array = pixel_array; bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan"); @@ -603,17 +615,6 @@ void RE_bake_pixels_populate( zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height, R.clipcrop); } - if ((uv_layer == NULL) || (uv_layer[0] == '\0')) { - mloopuv = CustomData_get_layer(&me->ldata, CD_MLOOPUV); - } - else { - int uv_id = CustomData_get_named_layer(&me->ldata, CD_MLOOPUV, uv_layer); - mloopuv = CustomData_get_layer_n(&me->ldata, CD_MTFACE, uv_id); - } - - if (mloopuv == NULL) - return; - looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__); BKE_mesh_recalc_looptri( |