fixed memory leak in table unpack code; added Valgrind suppression file
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 13 Oct 2016 11:33:04 +0000 (14:33 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 13 Oct 2016 11:33:25 +0000 (14:33 +0300)
doc/valgrind.supp [new file with mode: 0644]
src/libnetxms/table.cpp
tests/test-libnetxms/test-libnetxms.cpp

diff --git a/doc/valgrind.supp b/doc/valgrind.supp
new file mode 100644 (file)
index 0000000..c1e33c1
--- /dev/null
@@ -0,0 +1,95 @@
+{
+       dlopen
+       Memcheck:Leak
+       fun:malloc
+       ...
+       fun:_dl_init
+       fun:dl_open_worker
+}
+
+{
+       pthread_create
+       Memcheck:Leak
+       fun:calloc
+       fun:allocate_dtv
+       fun:_dl_allocate_tls
+       fun:allocate_stack
+}
+
+{
+       start_thread
+       Memcheck:Leak
+       fun:realloc
+       ...
+       fun:start_thread
+       fun:clone
+}
+
+{
+       OpenSSL/condition
+       Memcheck:Cond
+       obj:*/libcrypto.so.1.0.0
+}
+
+{
+       OpenSSL/value8
+       Memcheck:Value8
+       obj:*/libcrypto.so.1.0.0
+}
+
+{
+       OpenSSL/value4
+       Memcheck:Value4
+       obj:*/libcrypto.so.1.0.0
+}
+
+{
+       uninit bytes in agent send message
+       Memcheck:Param
+       socketcall.sendto
+       fun:send
+       fun:_Z6SendExiPKvmiP14netxms_mutex_t
+       fun:_ZN11CommSession14sendRawMessageEP12NXCP_MESSAGEP21NXCPEncryptionContext
+}
+
+{
+       decryptMessage/jump
+       Memcheck:Cond
+       ...
+       fun:_ZN21NXCPEncryptionContext14decryptMessageEP22NXCP_ENCRYPTED_MESSAGEPh
+       fun:_ZN23AbstractMessageReceiver20getMessageFromBufferEPb
+       fun:_ZN23AbstractMessageReceiver11readMessageEjP21MessageReceiverResult
+}
+
+{
+       decryptMessage/value8
+       Memcheck:Value8
+       ...
+       fun:_ZN21NXCPEncryptionContext14decryptMessageEP22NXCP_ENCRYPTED_MESSAGEPh
+       fun:_ZN23AbstractMessageReceiver20getMessageFromBufferEPb
+       fun:_ZN23AbstractMessageReceiver11readMessageEjP21MessageReceiverResult
+}
+
+{
+       NXCPMessage/jump
+       Memcheck:Cond
+       fun:_ZN11NXCPMessageC1EP12NXCP_MESSAGEi
+       fun:_ZN23AbstractMessageReceiver20getMessageFromBufferEPb
+       fun:_ZN23AbstractMessageReceiver11readMessageEjP21MessageReceiverResult
+}
+
+{
+       iconv/jump
+       Memcheck:Cond
+       ...
+       fun:__gconv
+       fun:iconv
+}
+
+{
+       iconv/value8
+       Memcheck:Value8
+       ...
+       fun:__gconv
+       fun:iconv
+}
index 2c84dcd..63c9d3d 100644 (file)
@@ -326,9 +326,11 @@ Table *Table::createFromPackedXML(const char *packedXml)
    if (uncompress((BYTE *)xml, &uncompSize, (BYTE *)&compressedXml[4], (uLong)compressedSize - 4) != Z_OK)
    {
       free(xml);
+      free(compressedXml);
       return NULL;
    }
    xml[xmlSize] = 0;
+   free(compressedXml);
 
    Table *table = new Table();
    if (table->parseXML(xml))
index 925d6bd..f8dfb1d 100644 (file)
@@ -629,6 +629,9 @@ static void TestTable()
    AssertEquals(table2->getNumRows(), table->getNumRows());
    AssertEquals(table2->getAsInt(10, 1), table->getAsInt(10, 1));
    EndTest(GetCurrentTimeMs() - start);
+
+   delete table;
+   delete table2;
 }
 
 /**