Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary ownership model seems error prone #1242

Open
aconverse opened this issue Oct 30, 2023 · 2 comments
Open

Dictionary ownership model seems error prone #1242

aconverse opened this issue Oct 30, 2023 · 2 comments

Comments

@aconverse
Copy link

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.

@aconverse
Copy link
Author

aconverse commented Oct 31, 2023

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.

@kylophone
Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants