shithub: dav1d

Download patch

ref: 8308f4b5adc0c42649e9226534966bc4efb49eea
parent: c7007c923a825f4d6b928e7afc24a6b1d6bcc98d
author: Michael Bradshaw <[email protected]>
date: Thu Jan 3 06:07:30 EST 2019

Only set Dav1dRef's data field in dav1d_ref_create

--- a/src/ref.c
+++ b/src/ref.c
@@ -46,6 +46,8 @@
     res = dav1d_ref_wrap(data, default_free_callback, data);
     if (!res) {
         free(data);
+    } else {
+        res->data = data;
     }
 
     return res;
@@ -58,8 +60,7 @@
     Dav1dRef *res = malloc(sizeof(Dav1dRef));
     if (!res) return NULL;
 
-    if (ptr == user_data)
-        res->data = user_data;
+    res->data = NULL;
     res->const_data = ptr;
     atomic_init(&res->ref_cnt, 1);
     res->free_callback = free_callback;
@@ -86,5 +87,5 @@
 }
 
 int dav1d_ref_is_writable(Dav1dRef *const ref) {
-    return atomic_load(&ref->ref_cnt) == 1;
+    return atomic_load(&ref->ref_cnt) == 1 && ref->data;
 }