Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


New commits:
commit 0a38e49ee801be8e754cbf7b800aaab5da392c6d
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Sun Jul 23 19:17:41 2017 +0100

    coverity#1415617 Resource leak

    Change-Id: Ib23bbd9403f44fd7aa3635a3febb6533b1f9edad

diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx
index fcf227eb2541..a2f20058b36e 100644
--- a/sal/qa/osl/pipe/osl_Pipe.cxx
+++ b/sal/qa/osl/pipe/osl_Pipe.cxx
@@ -172,12 +172,12 @@ namespace osl_Pipe
         void ctors_no_acquire( )
             {
                 /// create a pipe.
-                ::osl::Pipe* pPipe = new ::osl::Pipe(
test::uniquePipeName(aTestPipeName),
osl_Pipe_CREATE );
+                std::unique_ptr<osl::Pipe> xPipe(new
osl::Pipe(test::uniquePipeName(aTestPipeName),
osl_Pipe_CREATE));
                 /// constructs a pipe reference without acquiring the
handle.
-                ::osl::Pipe* pNoAcquirePipe = new ::osl::Pipe(
pPipe->getHandle( ), SAL_NO_ACQUIRE );
+                std::unique_ptr<osl::Pipe> xNoAcquirePipe(new
osl::Pipe(xPipe->getHandle(), SAL_NO_ACQUIRE));

-                StreamPipe aStreamPipe(pPipe->getHandle());
-                delete pNoAcquirePipe;
+                StreamPipe aStreamPipe(xPipe->getHandle());
+                xNoAcquirePipe.reset();
                 int nRet = aStreamPipe.send("a", 1);

                 if (nRet >= 0)



I think this memory leak is actually required in this case. SAL_NO_ACQUIRE
means that the ref count of the internal pipe object is not incremented and
therefore during the destruction of the osl::Pipe we are now deleting the
same internal object twice.

I think this can be seen in
https://ci.libreoffice.org/job/lo_ubsan/611/consoleFull and IMHO the
easiest fix might be to just annotate that test for coverity. Maybe someone
has a better idea.

Regards,
Markus

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.