From 010a9c0b00aa6c8ce8fdcb60c79d70d71f5c4022 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Fri, 5 Jun 2009 03:52:24 +0000 Subject: [PATCH] coverity issues: CID: 506 Checker: REVERSE_INULL (help) File: base/src/source/blender/src/editparticle.c Function: PE_mirror_x Description: Pointer "(edit)->keys" dereferenced before NULL check and CID: 507 Checker: REVERSE_INULL (help) File: base/src/source/blender/src/editparticle.c Function: PE_mirror_x Description: Pointer "(psys)->particles" dereferenced before NULL check No need to copy the memory if the pointer isn't valid. Kent --- source/blender/src/editparticle.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/src/editparticle.c b/source/blender/src/editparticle.c index d48b84789d8..f91b2a0d435 100644 --- a/source/blender/src/editparticle.c +++ b/source/blender/src/editparticle.c @@ -2844,13 +2844,16 @@ void PE_mirror_x(int tagged) new_pars= MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new"); new_keys= MEM_callocN(newtotpart*sizeof(ParticleEditKey*), "ParticleEditKey new"); - memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData)); - memcpy(new_keys, edit->keys, totpart*sizeof(ParticleEditKey*)); - - if(psys->particles) MEM_freeN(psys->particles); + if(psys->particles) { + memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData)); + MEM_freeN(psys->particles); + } psys->particles= new_pars; - if(edit->keys) MEM_freeN(edit->keys); + if(edit->keys) { + memcpy(new_keys, edit->keys, totpart*sizeof(ParticleEditKey*)); + MEM_freeN(edit->keys); + } edit->keys= new_keys; if(edit->mirror_cache) {