| 115 | } |
| 116 | |
| 117 | static void buffer_replace(AVBufferRef **dst, AVBufferRef **src) |
| 118 | { |
| 119 | AVBuffer *b; |
| 120 | |
| 121 | b = (*dst)->buffer; |
| 122 | |
| 123 | if (src) { |
| 124 | **dst = **src; |
| 125 | av_freep(src); |
| 126 | } else |
| 127 | av_freep(dst); |
| 128 | |
| 129 | if (atomic_fetch_sub_explicit(&b->refcount, 1, memory_order_acq_rel) == 1) { |
| 130 | /* b->free below might already free the structure containing *b, |
| 131 | * so we have to read the flag now to avoid use-after-free. */ |
| 132 | int free_avbuffer = !(b->flags_internal & BUFFER_FLAG_NO_FREE); |
| 133 | b->free(b->opaque, b->data); |
| 134 | if (free_avbuffer) |
| 135 | av_free(b); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | void av_buffer_unref(AVBufferRef **buf) |
| 140 | { |
no test coverage detected