From d97845a693c28b8d56934c1b34bdb5c346a2603b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Dec 2020 16:46:04 +1100 Subject: BLI_string: return NULL from BLI_str_quoted_substrN on failure This was returning an empty allocated string, however almost all callers checked if the return value was NULL before freeing, making for misunderstandings on the intended use of this function. BCAnimationSampler::initialize_curves for example detected the f-curves animation type to 'bone' based on a non-NULL return value which never failed. Also fixes two leaks where the the result of BLI_str_quoted_substrN wasn't freed. --- source/blender/editors/animation/anim_deps.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/animation/anim_deps.c') diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index e552a321bca..32ce78e405e 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -216,11 +216,13 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale) /* get strip name, and check if this strip is selected */ char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); - Sequence *seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false); - if (seq_name) { - MEM_freeN(seq_name); + if (seq_name == NULL) { + return; } + Sequence *seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false); + MEM_freeN(seq_name); + if (seq == NULL) { return; } -- cgit v1.2.3