Fixed the move assignment operator to check for self-assignment

This commit is contained in:
Klaus Schmidinger 2024-02-15 14:57:56 +01:00
parent 29200d040e
commit 2c66d57d4b
3 changed files with 12 additions and 4 deletions

View File

@ -3596,6 +3596,7 @@ Stefan Herdler <herdler@gmx.de>
for adding failsafe defaults for 'make LCLBLD=1' to the Makefile
for reporting the index file of a recording not being regenerated in case it is
present, but empty
for reporting a missing check for self-assignment in the move assignment operator
Tobias Faust <tobias.faust@gmx.de>
for the original "jumpingseconds" patch

View File

@ -9886,3 +9886,8 @@ Video Disk Recorder Revision History
(thanks to Christoph Haubrich).
- Fixed possible duplicate component entries in the info of an ongoing recording
(reported by Christoph Haubrich).
2024-02-15:
- Fixed the move assignment operator to check for self-assignment (suggested by
Stefan Herdler).

10
tools.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: tools.c 5.9 2024/01/20 13:59:55 kls Exp $
* $Id: tools.c 5.10 2024/02/15 14:57:56 kls Exp $
*/
#include "tools.h"
@ -1108,9 +1108,11 @@ cString &cString::operator=(const cString &String)
cString &cString::operator=(cString &&String)
{
free(s);
s = String.s;
String.s = NULL;
if (this != &String) {
free(s);
s = String.s;
String.s = NULL;
}
return *this;
}