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

Fix frame double-free #1368

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libvmaf/src/picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ int vmaf_picture_unref(VmafPicture *pic) {
if (!pic) return -EINVAL;
if (!pic->ref) return -EINVAL;

vmaf_ref_fetch_decrement(pic->ref);
if (vmaf_ref_load(pic->ref) == 0) {
const long old_cnt = vmaf_ref_fetch_decrement(pic->ref);
if (old_cnt == 1) {
const VmafPicturePrivate *priv = pic->priv;
priv->release_picture(pic, priv->cookie);
free(pic->priv);
Expand Down
4 changes: 2 additions & 2 deletions libvmaf/src/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ void vmaf_ref_fetch_increment(VmafRef *ref)
atomic_fetch_add(&ref->cnt, 1);
}

void vmaf_ref_fetch_decrement(VmafRef *ref)
long vmaf_ref_fetch_decrement(VmafRef *ref)
{
atomic_fetch_sub(&ref->cnt, 1);
return atomic_fetch_sub(&ref->cnt, 1);
}

long vmaf_ref_load(VmafRef *ref)
Expand Down
2 changes: 1 addition & 1 deletion libvmaf/src/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct VmafRef {

int vmaf_ref_init(VmafRef **ref);
void vmaf_ref_fetch_increment(VmafRef *ref);
void vmaf_ref_fetch_decrement(VmafRef *ref);
long vmaf_ref_fetch_decrement(VmafRef *ref);
long vmaf_ref_load(VmafRef *ref);
int vmaf_ref_close(VmafRef *ref);

Expand Down
Loading