[Libreoffice-commits] core.git: xmlsecurity/source

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Wed Jun 28 09:11:57 UTC 2017


 xmlsecurity/source/gpg/CertificateImpl.cxx      |    7 +++++--
 xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 9a884b3d055ffdedbadb64c7f14e6d38078dedb1
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Wed Jun 28 09:12:35 2017 +0200

    gpg4libre: Don't call production code inside an assert()
    
    Won't work in non-debug builds
    
    Change-Id: I64f9c416890ddd02ec8efc0f59ded145cc17896a
    Reviewed-on: https://gerrit.libreoffice.org/39345
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/xmlsecurity/source/gpg/CertificateImpl.cxx b/xmlsecurity/source/gpg/CertificateImpl.cxx
index 20fa35c52d5d..03fa49cdef68 100644
--- a/xmlsecurity/source/gpg/CertificateImpl.cxx
+++ b/xmlsecurity/source/gpg/CertificateImpl.cxx
@@ -217,14 +217,17 @@ void CertificateImpl::setCertificate(GpgME::Context* ctx, const GpgME::Key& key)
     if (err)
         throw RuntimeException("The GpgME library failed to retrieve the public key");
 
-    assert(data_out.seek(0,SEEK_SET) == 0);
+    off_t result = data_out.seek(0,SEEK_SET);
+    (void) result;
+    assert(result == 0);
     int len=0, curr=0; char buf;
     while( (curr=data_out.read(&buf, 1)) )
         len += curr;
 
     // write bits to sequence of bytes
     m_aBits.realloc(len);
-    assert(data_out.seek(0,SEEK_SET) == 0);
+    result = data_out.seek(0,SEEK_SET);
+    assert(result == 0);
     if( data_out.read(m_aBits.getArray(), len) != len )
         throw RuntimeException("The GpgME library failed to read the key");
 }
diff --git a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
index 8de25b9a4f14..8cec0ceb6fe7 100644
--- a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
+++ b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
@@ -205,7 +205,9 @@ SAL_CALL XMLSignature_GpgImpl::generate(
     rCtx.setArmor(false);
     GpgME::SigningResult sign_res=rCtx.sign(data_in, data_out,
                                             GpgME::Detached);
-    assert(data_out.seek(0,SEEK_SET) == 0);
+    off_t result = data_out.seek(0,SEEK_SET);
+    (void) result;
+    assert(result == 0);
     int len=0, curr=0; char buf;
     while( (curr=data_out.read(&buf, 1)) )
         len += curr;
@@ -217,7 +219,8 @@ SAL_CALL XMLSignature_GpgImpl::generate(
     xmlChar* signature = static_cast<xmlChar*>(xmlMalloc(len + 1));
     if(signature == nullptr)
         throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
-    assert(data_out.seek(0,SEEK_SET) == 0);
+    result = data_out.seek(0,SEEK_SET);
+    assert(result == 0);
     if( data_out.read(signature, len) != len )
         throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
 


More information about the Libreoffice-commits mailing list