On 6/23/22 12:12, Rémi Bernon wrote:
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/winegstreamer/wg_transform.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index e05432f6ac7..b0048fad644 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -314,10 +314,15 @@ static struct wg_sample *transform_request_sample(gsize size, void *context)
GST_LOG("size %#zx, context %p", size, transform);
- sample = InterlockedExchangePointer((void **)&transform->output_wg_sample, NULL);
- if (!sample || sample->max_size < size)
if (!(sample = InterlockedExchangePointer((void **)&transform->output_wg_sample, NULL))) return NULL;
if (sample->max_size < size)
{
InterlockedDecrement(&sample->refcount);
return NULL;
}
return sample;
}
I'll sign off on this because it's an improvement over the current code, but on reflection I think this pattern is not very idiomatic. More idiomatic would be to protect the whole thing with a lock, and not set the pointer to NULL in this function (but instead add an extra reference).