From 54204058a4311db5526d189b59efd75522dc4416 Mon Sep 17 00:00:00 2001 From: fgallegosalido Date: Sat, 16 Jan 2021 18:39:09 +0100 Subject: [PATCH] Fixed copy assign operator in sf::Sound so it checks for self-assignment --- src/SFML/Audio/Sound.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index 4643bd5d6..59513a105 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -160,6 +160,10 @@ Sound& Sound::operator =(const Sound& right) // the list of sound instances contained in the buffers and unnecessarily // destroy/create OpenAL sound sources + // Handle self-assignment here, as no copy-and-swap idiom is being used + if (this == &right) + return *this; + // Delegate to base class, which copies all the sound attributes SoundSource::operator=(right);