gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Jul 24 01:39:22 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/867867da (commit)
via https://github.com/Gnucash/gnucash/commit/920f760d (commit)
via https://github.com/Gnucash/gnucash/commit/cdc5b6a7 (commit)
via https://github.com/Gnucash/gnucash/commit/a3684472 (commit)
via https://github.com/Gnucash/gnucash/commit/30b47d16 (commit)
via https://github.com/Gnucash/gnucash/commit/49240e9b (commit)
via https://github.com/Gnucash/gnucash/commit/2f0c0451 (commit)
via https://github.com/Gnucash/gnucash/commit/394823a7 (commit)
via https://github.com/Gnucash/gnucash/commit/47f76fcf (commit)
via https://github.com/Gnucash/gnucash/commit/1943caee (commit)
via https://github.com/Gnucash/gnucash/commit/8ac3ab60 (commit)
via https://github.com/Gnucash/gnucash/commit/26409119 (commit)
via https://github.com/Gnucash/gnucash/commit/d808fddc (commit)
via https://github.com/Gnucash/gnucash/commit/b7d27855 (commit)
via https://github.com/Gnucash/gnucash/commit/378dc405 (commit)
via https://github.com/Gnucash/gnucash/commit/69df6ea5 (commit)
via https://github.com/Gnucash/gnucash/commit/f1e889db (commit)
via https://github.com/Gnucash/gnucash/commit/4c48134d (commit)
via https://github.com/Gnucash/gnucash/commit/e4398237 (commit)
from https://github.com/Gnucash/gnucash/commit/312a82e9 (commit)
commit 867867da53d4b1d161d0c6554dbcbddaf1f4450d
Merge: 920f760dd8 2640911901
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jul 24 13:09:55 2023 +0800
Merge Richard Cohen branch 'fix-leaks-in-tests' into stable #1713
commit 920f760dd8fede4f73cec7a89cce2d453d79ff43
Merge: cdc5b6a796 1943caee55
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jul 24 13:08:38 2023 +0800
Merge Richard Cohen branch 'fix-some-leaks-on-error-path' into stable #1714
commit cdc5b6a7968ebffc1b08f0178799a64dba3cc19a
Merge: 312a82e997 a36844720d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jul 24 13:07:40 2023 +0800
Merge Richard Cohen branch 'fix-test-leaks-from-get-random-string' into stable #1715
commit a36844720d796a4dff681fbc33a4ccc5667b1abd
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 15:06:52 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-vendor
==88804== 8 bytes in 1 blocks are definitely lost in loss record 12 of 479
==88804== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88804== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88804== by 0x10B5D8: get_random_string_without (test-stuff.c:312)
==88804== by 0x10B655: get_random_string (test-stuff.c:333)
==88804== by 0x10AA92: test_string_fcn (test-vendor.c:138)
==88804== by 0x10A76B: test_vendor (test-vendor.c:88)
==88804== by 0x10AD5A: main (test-vendor.c:246)
+ 3 more
diff --git a/libgnucash/engine/test/test-vendor.c b/libgnucash/engine/test/test-vendor.c
index 8e3e19cfd7..47bdb057d7 100644
--- a/libgnucash/engine/test/test-vendor.c
+++ b/libgnucash/engine/test/test-vendor.c
@@ -117,13 +117,13 @@ test_vendor (void)
g_list_free (list);
}
{
- const char *str = get_random_string();
- const char *res;
+ char *str = get_random_string();
gncVendorSetName (vendor, str);
- res = qof_object_printable (GNC_ID_VENDOR, vendor);
+ const char *res = qof_object_printable (GNC_ID_VENDOR, vendor);
do_test (res != NULL, "Printable NULL?");
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
+ g_free (str);
}
qof_book_destroy (book);
@@ -135,7 +135,7 @@ test_string_fcn (QofBook *book, const char *message,
const char * (*get)(const GncVendor *))
{
GncVendor *vendor = gncVendorCreate (book);
- char const *str = get_random_string ();
+ char *str = get_random_string ();
do_test (!gncVendorIsDirty (vendor), "test if start dirty");
gncVendorBeginEdit (vendor);
@@ -150,6 +150,7 @@ test_string_fcn (QofBook *book, const char *message,
*/
// do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
do_test (g_strcmp0 (get (vendor), str) == 0, message);
+ g_free (str);
gncVendorSetActive (vendor, FALSE);
count++;
}
commit 30b47d16691df008440949d1d7c73db6154c1afb
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 18:21:31 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-job
==88779== 8 bytes in 1 blocks are definitely lost in loss record 9 of 461
==88779== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88779== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88779== by 0x10B871: get_random_string_without (test-stuff.c:312)
==88779== by 0x10B8EE: get_random_string (test-stuff.c:333)
==88779== by 0x10AB9F: test_string_fcn (test-job.c:157)
==88779== by 0x10A7B1: test_job (test-job.c:87)
==88779== by 0x10AFF3: main (test-job.c:262)
+ 3 more
diff --git a/libgnucash/engine/test/test-job.c b/libgnucash/engine/test/test-job.c
index 2b5b4f8155..737f168017 100644
--- a/libgnucash/engine/test/test-job.c
+++ b/libgnucash/engine/test/test-job.c
@@ -113,13 +113,13 @@ test_job (void)
}
#endif
{
- const char *str = get_random_string();
- const char *res;
+ char *str = get_random_string();
gncJobSetName (job, str);
- res = qof_object_printable (GNC_ID_JOB, job);
+ const char *res = qof_object_printable (GNC_ID_JOB, job);
do_test (res != NULL, "Printable NULL?");
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
+ g_free (str);
}
{
GList *list;
@@ -154,7 +154,7 @@ test_string_fcn (QofBook *book, const char *message,
const char * (*get)(const GncJob *))
{
GncJob *job = gncJobCreate (book);
- char const *str = get_random_string ();
+ char *str = get_random_string ();
do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty");
gncJobBeginEdit (job);
@@ -169,6 +169,7 @@ test_string_fcn (QofBook *book, const char *message,
*/
// do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
do_test (g_strcmp0 (get (job), str) == 0, message);
+ g_free (str);
gncJobSetActive (job, FALSE);
count++;
}
commit 49240e9b5acfbe873406b39ce46b5cdb49c79173
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 16:46:19 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-employee
==88366== 8 bytes in 1 blocks are definitely lost in loss record 11 of 474
==88366== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88366== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88366== by 0x10B7E9: get_random_string_without (test-stuff.c:312)
==88366== by 0x10B866: get_random_string (test-stuff.c:333)
==88366== by 0x10AB64: test_string_fcn (test-employee.c:140)
==88366== by 0x10A7C1: test_employee (test-employee.c:87)
==88366== by 0x10AF6B: main (test-employee.c:246)
+ 4 more
diff --git a/libgnucash/engine/test/test-employee.c b/libgnucash/engine/test/test-employee.c
index 1010febf36..cfefd2e214 100644
--- a/libgnucash/engine/test/test-employee.c
+++ b/libgnucash/engine/test/test-employee.c
@@ -117,15 +117,14 @@ test_employee (void)
g_list_free (list);
}
{
- const char *str = get_random_string();
- const char *res;
- GncAddress *addr;
+ char *str = get_random_string();
- addr = gncEmployeeGetAddr (employee);
+ GncAddress *addr = gncEmployeeGetAddr (employee);
gncAddressSetName (addr, str);
- res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
+ const char *res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
do_test (res != NULL, "Printable NULL?");
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
+ g_free (str);
}
qof_book_destroy (book);
@@ -137,7 +136,7 @@ test_string_fcn (QofBook *book, const char *message,
const char * (*get)(const GncEmployee *))
{
GncEmployee *employee = gncEmployeeCreate (book);
- char const *str = get_random_string ();
+ char *str = get_random_string ();
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
gncEmployeeBeginEdit (employee);
@@ -152,6 +151,7 @@ test_string_fcn (QofBook *book, const char *message,
*/
// do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
do_test (g_strcmp0 (get (employee), str) == 0, message);
+ g_free (str);
gncEmployeeSetActive (employee, FALSE);
count++;
}
commit 2f0c04518791de3b3553f259a1138e83b7d77380
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 15:03:38 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-customer
==88327== 8 bytes in 1 blocks are definitely lost in loss record 13 of 667
==88327== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88327== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88327== by 0x10B890: get_random_string_without (test-stuff.c:312)
==88327== by 0x10B90D: get_random_string (test-stuff.c:333)
==88327== by 0x10AC7A: test_string_fcn (test-customer.c:146)
==88327== by 0x10A82E: test_customer (test-customer.c:79)
==88327== by 0x10B012: main (test-customer.c:229)
+ 3 more
diff --git a/libgnucash/engine/test/test-customer.c b/libgnucash/engine/test/test-customer.c
index fc3cc52eca..b3f5bac789 100644
--- a/libgnucash/engine/test/test-customer.c
+++ b/libgnucash/engine/test/test-customer.c
@@ -111,16 +111,16 @@ test_customer (void)
g_list_free (list);
}
{
- const char *str = get_random_string();
- const char *res;
+ char *str = get_random_string();
- res = NULL;
gncCustomerBeginEdit(customer);
gncCustomerSetName (customer, str);
gncCustomerCommitEdit(customer);
- res = qof_object_printable (GNC_ID_CUSTOMER, customer);
+
+ const char *res = qof_object_printable (GNC_ID_CUSTOMER, customer);
do_test (res != NULL, "Printable NULL?");
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
+ g_free (str);
}
do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
@@ -143,7 +143,7 @@ test_string_fcn (QofBook *book, const char *message,
const char * (*get)(const GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (book);
- char const *str = get_random_string ();
+ char *str = get_random_string ();
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
gncCustomerBeginEdit (customer);
@@ -158,6 +158,7 @@ test_string_fcn (QofBook *book, const char *message,
*/
// do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
do_test (g_strcmp0 (get (customer), str) == 0, message);
+ g_free (str);
gncCustomerSetActive (customer, FALSE);
count++;
}
commit 394823a7345f40543c3b506c657570e9e08f6a3a
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 17:47:15 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-commodities
==88718== 8 bytes in 1 blocks are definitely lost in loss record 21 of 1,880
==88718== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88718== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88718== by 0x11D6B9: get_random_string_without (test-stuff.c:312)
==88718== by 0x11D736: get_random_string (test-stuff.c:333)
==88718== by 0x116A91: test_commodity() (test-commodities.cpp:60)
==88718== by 0x117355: main (test-commodities.cpp:196)
+ 5 more
diff --git a/libgnucash/engine/test/test-commodities.cpp b/libgnucash/engine/test/test-commodities.cpp
index 089880f9dc..7ed5871678 100644
--- a/libgnucash/engine/test/test-commodities.cpp
+++ b/libgnucash/engine/test/test-commodities.cpp
@@ -72,6 +72,7 @@ test_commodity(void)
do_test(
g_strcmp0(fullname, gnc_commodity_get_fullname(com)) == 0,
"fullnames equal test");
+ g_free (fullname);
do_test(
g_strcmp0(name_space, gnc_commodity_get_namespace(com)) == 0,
@@ -80,10 +81,12 @@ test_commodity(void)
do_test(
g_strcmp0(mnemonic, gnc_commodity_get_mnemonic(com)) == 0,
"mnemonic equal test");
+ g_free (mnemonic);
do_test(
g_strcmp0(cusip, gnc_commodity_get_cusip(com)) == 0,
"cusip equal test");
+ g_free (cusip);
do_test(
gnc_commodity_get_fraction(com) == fraction,
@@ -126,6 +129,10 @@ test_commodity(void)
com2 = gnc_commodity_new(book, fullname, name_space, mnemonic,
cusip, fraction);
+ g_free (fullname);
+ g_free (mnemonic);
+ g_free (cusip);
+
do_test(
gnc_commodity_equiv(com, com2), "commodity equiv");
commit 47f76fcf0332695c03ef103f284112e94801c1a6
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri Jul 7 17:47:04 2023 +0100
Valgrind: fix "definitely lost" memory from get_random_string() - test-address
==88262== 6 bytes in 1 blocks are definitely lost in loss record 5 of 2,117
==88262== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88262== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88262== by 0x10B043: get_random_string_without (test-stuff.c:312)
==88262== by 0x10B0C0: get_random_string (test-stuff.c:333)
==88262== by 0x10A6E0: test_string_fcn (test-address.c:79)
==88262== by 0x10A694: test_address (test-address.c:69)
==88262== by 0x10A7C5: main (test-address.c:94)
+ 7 more
diff --git a/libgnucash/engine/test/test-address.c b/libgnucash/engine/test/test-address.c
index 334da191d6..df620a8169 100644
--- a/libgnucash/engine/test/test-address.c
+++ b/libgnucash/engine/test/test-address.c
@@ -76,12 +76,13 @@ test_string_fcn (GncAddress *address, const char *message,
void (*set) (GncAddress *, const char *str),
const char * (*get)(const GncAddress *))
{
- char const *str = get_random_string ();
+ char *str = get_random_string ();
do_test (!gncAddressIsDirty (address), "test if start dirty");
set (address, str);
do_test (gncAddressIsDirty (address), "test dirty later");
do_test (g_strcmp0 (get (address), str) == 0, message);
+ g_free (str);
gncAddressClearDirty (address);
}
commit 1943caee5591d2dee6f68c06f83210333f0dac5b
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Wed Jul 5 17:33:26 2023 +0100
Fix memory leak on error path in text_to_dom_tree()
diff --git a/libgnucash/backend/xml/sixtp-dom-generators.cpp b/libgnucash/backend/xml/sixtp-dom-generators.cpp
index 3a90aae72e..fca3563bbc 100644
--- a/libgnucash/backend/xml/sixtp-dom-generators.cpp
+++ b/libgnucash/backend/xml/sixtp-dom-generators.cpp
@@ -46,14 +46,16 @@ boolean_to_dom_tree (const char* tag, gboolean val)
xmlNodePtr
text_to_dom_tree (const char* tag, const char* str)
{
- xmlNodePtr result;
- gchar* newstr = g_strdup (str);
g_return_val_if_fail (tag, NULL);
g_return_val_if_fail (str, NULL);
- result = xmlNewNode (NULL, BAD_CAST tag);
+
+ xmlNodePtr result = xmlNewNode (NULL, BAD_CAST tag);
g_return_val_if_fail (result, NULL);
+
+ gchar* newstr = g_strdup (str);
xmlNodeAddContent (result, checked_char_cast (newstr));
g_free (newstr);
+
return result;
}
commit 8ac3ab6065d79b3245f3e7ddae680f2df4cbb6fd
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu Jul 6 17:01:34 2023 +0100
Valgrind: fix "definitely lost" memory on error path - test-tokenizer
==54518== 147 (16 direct, 131 indirect) bytes in 1 blocks are definitely lost in loss record 246 of 267
==54518== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==54518== by 0x6349948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x6364C4C: g_slice_alloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x632E2EB: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x632E580: g_error_new_literal (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x632E64B: g_set_error_literal (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x632F3DB: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x632F9B7: g_file_get_contents (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==54518== by 0x49E5E35: GncTokenizer::load_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (gnc-tokenizer.cpp:51)
==54518== by 0x49F27A3: GncFwTokenizer::load_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (gnc-tokenizer-fw.cpp:116)
==54518== by 0x1920A9: GncTokenizerTest_load_file_nonexisting_Test::TestBody() (test-tokenizer.cpp:93)
diff --git a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
index d14ead25ba..5c1e054382 100644
--- a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
+++ b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
@@ -49,7 +49,11 @@ GncTokenizer::load_file(const std::string& path)
GError *error = nullptr;
if (!g_file_get_contents(path.c_str(), &raw_contents, &raw_length, &error))
- throw std::ifstream::failure(error->message);
+ {
+ std::string msg {error->message};
+ g_error_free (error);
+ throw std::ifstream::failure {msg};
+ }
m_raw_contents = raw_contents;
g_free(raw_contents);
commit 264091190144f44549673e5ab9dd617950b6b3c0
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Wed Jul 5 14:57:34 2023 +0100
Valgrind: fix "definitely lost/still reachable" memory in test - test-xml2-is-file
Valgrind uses "still reachable" because of the call to exit()
==87185== 94 bytes in 1 blocks are still reachable in loss record 193 of 241
==87185== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==87185== by 0x15C234: main (test-xml2-is-file.cpp:42)
==87185==
diff --git a/libgnucash/backend/xml/test/test-xml2-is-file.cpp b/libgnucash/backend/xml/test/test-xml2-is-file.cpp
index 717bb5e5b4..8e1cf27c02 100644
--- a/libgnucash/backend/xml/test/test-xml2-is-file.cpp
+++ b/libgnucash/backend/xml/test/test-xml2-is-file.cpp
@@ -19,7 +19,8 @@
\********************************************************************/
#include <config.h>
#include <stdlib.h>
-#include <string.h>
+
+#include <string>
#include "test-engine-stuff.h"
#include "io-gncxml-v2.h"
@@ -38,11 +39,9 @@ main (int argc, char** argv)
directory = "test-files/xml2";
}
- auto size{strlen (directory) + 1 + strlen (FILENAME) + 1};
- char* filename = static_cast<decltype (filename)> (malloc (size));
- snprintf (filename, size, "%s/%s", directory, FILENAME);
- do_test (gnc_is_xml_data_file_v2 (filename, NULL), "gnc_is_xml_data_file_v2");
+ auto filename = std::string{directory} + '/' + FILENAME;
+ do_test (gnc_is_xml_data_file_v2 (filename.c_str(), NULL), "gnc_is_xml_data_file_v2");
print_test_results ();
- exit (get_rv ());
+ return get_rv ();
}
commit d808fddc956909a27be08d728e6c2cfc8daa5253
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu Jul 6 16:11:29 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-userdata-dir-invalid-home
==66427== 128 bytes in 1 blocks are definitely lost in loss record 22 of 25
==66427== at 0x4843738: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==66427== by 0x49B85EF: g_realloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x49D6EF1: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x49D6F6F: g_string_sized_new (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x499AB00: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x499B2D8: g_build_filename (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x10A498: main (test-userdata-dir-invalid-home.c:74)
==66427==
diff --git a/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c b/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
index b81d521333..3ec1e98946 100644
--- a/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
+++ b/libgnucash/core-utils/test/test-userdata-dir-invalid-home.c
@@ -83,6 +83,8 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
* The code should fall back to using the temporary
* directory in that case. */
g_setenv("HOME", homedir, TRUE);
+ g_free (homedir);
+
for (i = 0; strs2[i].funcname != NULL; i++)
{
char *daout;
commit b7d278556f506715876b9c22f04b7a8243f078e3
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Tue Jul 18 16:20:47 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-string-converters
==68902== 8 bytes in 1 blocks are definitely lost in loss record 7 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x5225948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x5240ED2: g_strdup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x13135E: g_strdup_inline (gstrfuncs.h:321)
==68902== by 0x13135E: dom_tree_to_text(_xmlNode*) (sixtp-dom-parsers.cpp:500)
==68902== by 0x141758: test_bad_string() (test-string-converters.cpp:70)
==68902== by 0x1417D8: main (test-string-converters.cpp:82)
==68902==
==68902== 93 bytes in 5 blocks are definitely lost in loss record 199 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x5225948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x5240ED2: g_strdup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x13135E: g_strdup_inline (gstrfuncs.h:321)
==68902== by 0x13135E: dom_tree_to_text(_xmlNode*) (sixtp-dom-parsers.cpp:500)
==68902== by 0x14169B: test_string_converters() (test-string-converters.cpp:55)
==68902== by 0x1417D3: main (test-string-converters.cpp:81)
==68902==
==68902== 260 (120 direct, 140 indirect) bytes in 1 blocks are definitely lost in loss record 242 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x48D5B84: xmlNewNode (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.14)
==68902== by 0x133873: text_to_dom_tree(char const*, char const*) (sixtp-dom-generators.cpp:53)
==68902== by 0x141748: test_bad_string() (test-string-converters.cpp:68)
==68902== by 0x1417D8: main (test-string-converters.cpp:82)
==68902==
==68902== 1,353 (600 direct, 753 indirect) bytes in 5 blocks are definitely lost in loss record 248 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x48D5B84: xmlNewNode (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.14)
==68902== by 0x133873: text_to_dom_tree(char const*, char const*) (sixtp-dom-generators.cpp:53)
==68902== by 0x14168B: test_string_converters() (test-string-converters.cpp:54)
==68902== by 0x1417D3: main (test-string-converters.cpp:81)
==68902==
diff --git a/libgnucash/backend/xml/test/test-string-converters.cpp b/libgnucash/backend/xml/test/test-string-converters.cpp
index 22509aad04..c2baf05738 100644
--- a/libgnucash/backend/xml/test/test-string-converters.cpp
+++ b/libgnucash/backend/xml/test/test-string-converters.cpp
@@ -57,6 +57,9 @@ test_string_converters (void)
do_test_args (
g_strcmp0 (backout, mark) == 0,
"string converting", __FILE__, __LINE__, "with string %s", mark);
+
+ g_free (backout);
+ xmlFreeNode (test_node);
}
}
@@ -71,6 +74,9 @@ test_bad_string (void)
do_test_args (g_strcmp0 (backout, sanitized) == 0,
"string sanitizing", __FILE__, __LINE__,
"with string %s", badstr);
+
+ g_free (backout);
+ xmlFreeNode (test_node);
}
int
commit 378dc405859adf58875accd325b026e6a3c3529e
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Wed Jul 5 16:42:45 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-resolve-file-path
==91379== 19 bytes in 1 blocks are definitely lost in loss record 2 of 9
==91379== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==91379== by 0x48D1948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48ED5B0: g_strconcat (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48B845F: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48B869E: g_dir_make_tmp (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x10935E: main (test-resolve-file-path.c:71)
diff --git a/libgnucash/core-utils/test/test-resolve-file-path.c b/libgnucash/core-utils/test/test-resolve-file-path.c
index 7424af2544..66a8cce3e6 100644
--- a/libgnucash/core-utils/test/test-resolve-file-path.c
+++ b/libgnucash/core-utils/test/test-resolve-file-path.c
@@ -65,7 +65,7 @@ main(int argc, char **argv)
* used to pass invalid home directories manually. The
* test error messages should then show the system's temporary
* directory to be used instead */
- home_dir = argv[1];
+ home_dir = g_strdup (argv[1]);
else
/* Set up a fake home directory to play with */
home_dir = g_dir_make_tmp("gnucashXXXXXX", NULL);
@@ -105,6 +105,7 @@ main(int argc, char **argv)
g_free(daout);
}
+ g_free (home_dir);
print_test_results();
return get_rv();
}
commit 69df6ea57d14ec6cb761b74931a343a14ce66a79
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Wed Jul 5 15:43:27 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-qofquerycore
==87254== 40 (24 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 107 of 242
==87254== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==87254== by 0x503B948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==87254== by 0x502F909: g_list_prepend (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==87254== by 0x194E83: QofQueryCoreTest_construct_predicate_guid_Test::TestBody() (gtest-qofquerycore.cpp:94)
diff --git a/libgnucash/engine/test/gtest-qofquerycore.cpp b/libgnucash/engine/test/gtest-qofquerycore.cpp
index 2a5d340e8a..d428b9725a 100644
--- a/libgnucash/engine/test/gtest-qofquerycore.cpp
+++ b/libgnucash/engine/test/gtest-qofquerycore.cpp
@@ -102,6 +102,7 @@ TEST_F(QofQueryCoreTest, construct_predicate_guid)
EXPECT_TRUE (guid_equal (guid, (const GncGUID*)pdata->guids->data));
EXPECT_EQ (NULL, pdata->guids->next);
qof_query_core_predicate_free ((QofQueryPredData*) pdata);
+ g_list_free_full (guidlist, (GDestroyNotify)guid_free);
}
TEST_F(QofQueryCoreTest, construct_predicate_int32)
commit f1e889dbcb4aa91e11dd56706959b0ea1580e2e4
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Mon Jul 17 19:18:27 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-lots
==67054== 320 bytes in 32 blocks are definitely lost in loss record 2,213 of 2,238
==67054== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==67054== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==67054== by 0x118AD8: get_random_transaction_with_currency (test-engine-stuff.cpp:1395)
==67054== by 0x119897: add_random_transactions_to_book (test-engine-stuff.cpp:1848)
==67054== by 0x115FE8: run_test() (test-lots.cpp:99)
==67054== by 0x1160BF: main (test-lots.cpp:135)
==67054==
diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index 8e93239e75..c1a1960f3f 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -52,6 +52,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+
+#include <string>
+
#include <qof.h>
#include "Account.h"
@@ -1376,8 +1379,6 @@ get_random_transaction_with_currency(QofBook *book,
{
Transaction* trans;
KvpFrame *f;
- gint num;
- gchar *numstr;
if (!account_list)
{
@@ -1392,8 +1393,6 @@ get_random_transaction_with_currency(QofBook *book,
return NULL;
}
- numstr = g_new0(gchar, 10);
-
trans = xaccMallocTransaction(book);
xaccTransBeginEdit(trans);
@@ -1402,9 +1401,10 @@ get_random_transaction_with_currency(QofBook *book,
currency ? currency :
get_random_commodity (book));
- num = get_random_int_in_range (1, max_trans_num);
- g_snprintf(numstr, 10, "%d", num);
- xaccTransSetNum(trans, numstr);
+ gint num = get_random_int_in_range (1, max_trans_num);
+ auto numstr = std::to_string(num);
+ xaccTransSetNum(trans, numstr.c_str());
+
set_tran_random_string_from_array(trans, xaccTransSetDescription,
sane_descriptions);
trn_add_ran_time(trans, xaccTransSetDatePostedSecs);
commit 4c48134d91afd98586f3e5c081291be41af3b147
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu Jul 6 18:51:39 2023 +0100
Valgrind: fix "definitely lost" memory in test - test-import-backend
==66703== 24 bytes in 1 blocks are definitely lost in loss record 116 of 284
==66703== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==66703== by 0x4A79948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66703== by 0x4A6D909: g_list_prepend (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66703== by 0x31EB41: ImportBackendTest::SetUp() (gtest-import-backend.cpp:145)
diff --git a/gnucash/import-export/test/gtest-import-backend.cpp b/gnucash/import-export/test/gtest-import-backend.cpp
index 8fc035ba64..3cdfbdd9f6 100644
--- a/gnucash/import-export/test/gtest-import-backend.cpp
+++ b/gnucash/import-export/test/gtest-import-backend.cpp
@@ -156,6 +156,7 @@ protected:
m_import_acc->free();
m_dest_acc->free();
m_trans->free();
+ g_list_free (m_splitList);
m_split->free();
}
commit e43982375c7b0904636f286064ead2e5330f01e0
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu Jul 6 17:27:03 2023 +0100
Valgrind: fix "definitely lost" memory in test - sqlite3test
==64824== 171 (88 direct, 83 indirect) bytes in 1 blocks are definitely lost in loss record 392 of 418
==64824== at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==64824== by 0x528A935: qof_session_new (qofsession.cpp:148)
==64824== by 0x141832: main (sqlite3test.c:34)
diff --git a/bindings/python/sqlite3test.c b/bindings/python/sqlite3test.c
index b8c41889f4..9195bcd97d 100644
--- a/bindings/python/sqlite3test.c
+++ b/bindings/python/sqlite3test.c
@@ -36,6 +36,7 @@ int main()
qof_session_load(s, NULL);
qof_session_save(s, NULL);
qof_session_end(s);
+ qof_session_destroy(s);
unlink(TESTFILE);
return 0;
}
Summary of changes:
bindings/python/sqlite3test.c | 1 +
gnucash/import-export/csv-imp/gnc-tokenizer.cpp | 6 +++++-
gnucash/import-export/test/gtest-import-backend.cpp | 1 +
libgnucash/backend/xml/sixtp-dom-generators.cpp | 8 +++++---
libgnucash/backend/xml/test/test-string-converters.cpp | 6 ++++++
libgnucash/backend/xml/test/test-xml2-is-file.cpp | 11 +++++------
libgnucash/core-utils/test/test-resolve-file-path.c | 3 ++-
.../core-utils/test/test-userdata-dir-invalid-home.c | 2 ++
libgnucash/engine/test-core/test-engine-stuff.cpp | 14 +++++++-------
libgnucash/engine/test/gtest-qofquerycore.cpp | 1 +
libgnucash/engine/test/test-address.c | 3 ++-
libgnucash/engine/test/test-commodities.cpp | 7 +++++++
libgnucash/engine/test/test-customer.c | 11 ++++++-----
libgnucash/engine/test/test-employee.c | 12 ++++++------
libgnucash/engine/test/test-job.c | 9 +++++----
libgnucash/engine/test/test-vendor.c | 9 +++++----
16 files changed, 66 insertions(+), 38 deletions(-)
More information about the gnucash-changes
mailing list