Netflix / vmaf

Perceptual video quality assessment based on multi-method fusion.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dictionary ownership model seems error prone

aconverse opened this issue · comments

Functions like int vmaf_model_feature_overload(VmafModel *model, const char *feature_name, VmafFeatureDictionary *opts_dict) sometimes free the passed in dictionary and sometimes doesn't. It doesn't seem to signal if the dictionary has been cleaned up or not to the caller other than by statically analyzing different error paths within the function.

This seems to be asking for memory-leaks, double-frees, and use-after-frees.

IMO it would make more sense for functions that might free dictionaries to accept a VmafDictionary** and null the inner pointer on free that same way vmaf_dictionary_free works.

Another possible API changing approach would be to make the caller always free the dict. The caller needs to free it in error cases anyway.

Agree with you, thanks for the feedback. I think probably we'll need to deprecate this function and replace with a better API in the next libvmaf release (v3.0).