Commit 8308f4b5 authored by Michael Bradshaw's avatar Michael Bradshaw Committed by Ronald S. Bultje

Only set Dav1dRef's data field in dav1d_ref_create

parent c7007c92
Pipeline #3842 passed with stages
in 5 minutes and 14 seconds
...@@ -46,6 +46,8 @@ Dav1dRef *dav1d_ref_create(const size_t size) { ...@@ -46,6 +46,8 @@ Dav1dRef *dav1d_ref_create(const size_t size) {
res = dav1d_ref_wrap(data, default_free_callback, data); res = dav1d_ref_wrap(data, default_free_callback, data);
if (!res) { if (!res) {
free(data); free(data);
} else {
res->data = data;
} }
return res; return res;
...@@ -58,8 +60,7 @@ Dav1dRef *dav1d_ref_wrap(const uint8_t *const ptr, ...@@ -58,8 +60,7 @@ Dav1dRef *dav1d_ref_wrap(const uint8_t *const ptr,
Dav1dRef *res = malloc(sizeof(Dav1dRef)); Dav1dRef *res = malloc(sizeof(Dav1dRef));
if (!res) return NULL; if (!res) return NULL;
if (ptr == user_data) res->data = NULL;
res->data = user_data;
res->const_data = ptr; res->const_data = ptr;
atomic_init(&res->ref_cnt, 1); atomic_init(&res->ref_cnt, 1);
res->free_callback = free_callback; res->free_callback = free_callback;
...@@ -86,5 +87,5 @@ void dav1d_ref_dec(Dav1dRef **const pref) { ...@@ -86,5 +87,5 @@ void dav1d_ref_dec(Dav1dRef **const pref) {
} }
int dav1d_ref_is_writable(Dav1dRef *const ref) { int dav1d_ref_is_writable(Dav1dRef *const ref) {
return atomic_load(&ref->ref_cnt) == 1; return atomic_load(&ref->ref_cnt) == 1 && ref->data;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment