]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutlsxx: dh_params, rsa_params: actually assign values in operator=
authorDaiki Ueno <ueno@gnu.org>
Tue, 16 Feb 2021 06:51:10 +0000 (07:51 +0100)
committerDaiki Ueno <ueno@gnu.org>
Tue, 16 Feb 2021 06:51:10 +0000 (07:51 +0100)
The previous implementation assigned the value to a temporary variable
and then return it without assigning it to 'this'.  That is not only
contradictory to user's expectation but also cppcheck treats it as a
logic error.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/gnutlsxx.cpp

index ea1632174b0ccb3cad6e785a15813f4a2d106aca..3613502aba1c6c2242f52252be0a50911c5d846f 100644 (file)
@@ -950,7 +950,10 @@ psk_server_credentials::psk_server_credentials ():credentials
         throw (exception (ret));
       }
 
-    return *dst;
+    std::swap (this->params, dst->params);
+    delete dst;
+
+    return *this;
   }
 
 // RSA
@@ -1003,7 +1006,10 @@ psk_server_credentials::psk_server_credentials ():credentials
         throw (exception (ret));
       }
 
-    return *dst;
+    std::swap (this->params, dst->params);
+    delete dst;
+
+    return *this;
   }
 
   void rsa_params::import_raw (const gnutls_datum_t & m,