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.
This commit is contained in:
2020-12-10 16:46:04 +11:00
parent 3ec7cf64bc
commit d97845a693
10 changed files with 56 additions and 55 deletions

View File

@@ -448,6 +448,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object *
char *boneName = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
if (boneName) {
object_type = BC_ANIMATION_TYPE_BONE;
MEM_freeN(boneName);
}
}