From e5e0cc68f70d35e1849aeaf21c0ce68afd6a1f59 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 22 Oct 2018 09:32:39 +0100 Subject: pvs-studio: V794 The assignment operator should be protected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia443a0e61a091d877c8da26bf7d45bf4261f8669 Reviewed-on: https://gerrit.libreoffice.org/62166 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/canvas/vclwrapper.hxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'include/canvas') diff --git a/include/canvas/vclwrapper.hxx b/include/canvas/vclwrapper.hxx index 77cf8b705e11..0a80cb282986 100644 --- a/include/canvas/vclwrapper.hxx +++ b/include/canvas/vclwrapper.hxx @@ -95,17 +95,19 @@ namespace canvas // assignment to wrappee VCLObject& operator=( const VCLObject& rhs ) { - if( mpWrappee ) + if (this != &rhs) { - if( rhs.mpWrappee ) - *mpWrappee = *rhs.mpWrappee; + if( mpWrappee ) + { + if( rhs.mpWrappee ) + *mpWrappee = *rhs.mpWrappee; + } + else + { + if( rhs.mpWrappee ) + mpWrappee = new Wrappee( *rhs.mpWrappee ); + } } - else - { - if( rhs.mpWrappee ) - mpWrappee = new Wrappee( *rhs.mpWrappee ); - } - return *this; } -- cgit