Commit Graph

2332 Commits

Author SHA1 Message Date
Christopher Lam
cba7da30fd [gnc-date.cpp] specialise iso-8601 parsing where TZ=+0000
- avoid allocating new TZPtr
- parse y/m/d/h/m/s and construct PTime directly
- avoid boost's time_from_string which creates an std::string
2024-03-14 08:48:31 +08:00
Christopher Lam
27c16517e9 [gnc-numeric.cpp] shortcut parsing num/denom as gnc_numeric
The gnc_numeric is serialised as "num/denom" with no whitespace, and
denom > 0. This function takes advantage of std::from_chars to parse
it. The "num" serialisation is also optimised as a free side effect of
this function.
2024-03-11 19:16:06 +08:00
Christopher Lam
11da03bc67 [gtest-gnc-numeric.cpp] test int64 limits for GncNumeric 2024-03-11 19:15:48 +08:00
John Ralls
af18ea598e Bug 799093 - Cannot reconcile since v5.4
Covers the final case where having the reconcile window open and
auto-completing a transaction then deleting the transaction before
committing it leaves the transaction in the reconcile window.

We need to signal that the account is modified even if it isn't
because that's what the reconcile window is watching.
2024-03-11 10:20:02 +01:00
John Ralls
2db6988e25 Remove bogus include. 2024-03-01 15:31:35 -08:00
John Ralls
8ebac5b596 Bug 799213 - SIGSEGV caused by revising an auto completed transaction
Calling xaccSplitDestroy without also calling xaccSplitCommitEdit then
deleting the split list before calling xaccTransCommitEdit prevents
xaccSplitCommitEdit from being called on the supposedly deleted
splits. Not only does this leak them it leaves them in the book
potentially with a dangling parent pointer.
2024-02-29 14:29:40 -08:00
Christopher Lam
229d9300cf [engine-helpers.h] key is a const char*
thus allowing compilation in cpp with stricter type checking
2024-02-25 22:39:38 +08:00
Christopher Lam
c345fc9d3c add #ifdef __cplusplus extern "C" {} wrappers to .h files 2024-02-25 22:39:38 +08:00
Christopher Lam
6cb2eeeaa8 Merge branch 'more-engine-cpp' into stable #1866 2024-02-22 07:39:35 +08:00
John Ralls
226bfea108 Fix a bunch of UB errors from ASAN about mismatched function types.
The casts fool the compiler but not the UB sanitizer.
2024-02-20 15:33:11 -08:00
John Ralls
7bd97f15d0 Fix transaction delete use-after-free, take 2.
The problem with take 1 was that the duplicate split uses the same lot
and account pointers without adding itself to those lists, causing
checks in unit tests to fail.
2024-02-20 15:10:05 -08:00
John Ralls
8546aa975e Revert "Fix two use-after-free issues found by address sanitizer."
This reverts commit 4dbf803041.

The use-after free errors are caused by the compiler reordering the
steps in xaccSplitFree and Transaction's do_destroy. Unfortunately the
corrections here caused trouble in other places, leading to test failures.
2024-02-19 21:11:54 -08:00
John Ralls
4dbf803041 Fix two use-after-free issues found by address sanitizer. 2024-02-19 14:33:43 -08:00
Christopher Lam
28cc26f207 [gnc-commodities.cpp] gnc_new_iso_codes is a std::unordered_map 2024-02-19 11:21:24 +08:00
Geert Janssens
00640f9ded Replace naked for loops with C++ algorithms 2024-02-18 23:18:16 +08:00
Geert Janssens
0732436e44 A few NULL/nullptr related cleanups 2024-02-18 23:18:16 +08:00
Christopher Lam
17f422f97c [gnc-commodity.cpp] convert quote_sources to vector
- all quote sources are now vector
- get_quote_source_from_type to convert QuoteSourceType to vector<gnc_quote_source>
- the quote sources are modifiable, therefore cannot be const:
see gnc_quote_source_set_fq_installed
2024-02-18 23:17:55 +08:00
John Ralls
266ae2a931 Bug 798946 - start/end of current/last quarter have off-by-one error
Calculating the quarter offset when the current month is less than the
beginning month of the fiscal year was inverted.
2024-02-17 12:52:17 -08:00
Christopher Lam
164453a858 [gnc-commodity.cpp] gnc_quote_source_get_index searches index
we can now remove init
2024-02-17 22:55:41 +08:00
Christopher Lam
5d16d025a6 [gnc-commodity.cpp] gnc_quote_source_s is a cpp class
... this ensures the new_quote_sources vector now doesn't leak anymore.
2024-02-17 22:55:41 +08:00
Christopher Lam
770045c4a5 [gnc-quotes.cpp] remove sources_as_glist() 2024-02-17 22:55:41 +08:00
Christopher Lam
346499ae04 [gnc-commodity.cpp] gnc_quote_source_set_fq_installed takes a StrVec
instead of a GList* of strdup'd chars
2024-02-17 22:55:40 +08:00
Christopher Lam
47a1a56f16 [gnc-commodity.cpp] fq_version is a std::string
thus can free itself on exit
2024-02-17 22:55:40 +08:00
Christopher Lam
f49c2735e3 [gnc-commodity.cpp] initialize quote_sources at compile-time 2024-02-17 22:55:40 +08:00
Christopher Lam
d488faacb2 [gnc-commodity.cpp] Convert to cpp 2024-02-17 22:55:40 +08:00
Vincent Lucarelli
f5b7bf3401 removed old_internal_name from gnc_quote_source_s (deprecated) 2024-02-17 22:52:40 +08:00
Christopher Lam
9035391907 [test-commodities.cpp] add some tests for gnc_quote_sources 2024-02-17 22:43:52 +08:00
Christopher Lam
03c5309666 [gnc-lot.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
7d8d8f83be [Recurrence.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
783c3df3c0 [Transaction.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
fc5d7f872e [Split.cpp] convert to cpp 2024-02-09 17:23:51 +08:00
Christopher Lam
698cc23051 Add #ifdef __cplusplus extern "C" {} wrappers to .h files 2024-02-08 21:26:47 +08:00
Christopher Lam
928f9245e6 [gtest-gnc-numeric] add operator comparisons
with example int64 numbers
2024-01-29 08:55:56 +08:00
Christopher Lam
a301544376 Merge branch 'stock-acct-metadata' into stable #1858 2024-01-27 14:26:13 +08:00
Christopher Lam
688032b590 [app-utils/gnc-ui-balances.cpp] convert to cpp 2024-01-27 03:45:11 +08:00
Christopher Lam
9782918586 [account.cpp] add more account metadata - assoc account
the tag denotes the type of associated account eg. "dividend"
"capgains" "cash" "fees"
2024-01-26 20:54:20 +08:00
Alex Aycinena
54da44b3ca Update Form/Schedule line references for 2023 for the US Income Tax Report 2024-01-16 11:44:10 -08:00
John Ralls
c87d480b0d Move gnc_list_formatter from gnc-date to gnc-ui-util.
It has nothing at all to do with dates.
2024-01-06 18:16:31 -08:00
John Ralls
d52d226e5b Convert gnc-ui-util to C++. 2024-01-06 18:08:39 -08:00
John Ralls
b2fa3ef106 Bug 799210 - Bad encoding of accented chars in account names in...
"Import CSV" wizard

In MSWin the UnicodeString(char*) ctor assumes that the input string
is encoded in the current codepage, but the input to
gnc_list_formatter is encoded in UTF8. Use the static class function
UnicodeString::fromUTF8 instead.
2024-01-06 10:30:14 -08:00
John Ralls
e22a57ad26 Merge John Ralls's 'asan' into stable. 2023-12-08 14:56:29 -08:00
John Ralls
6834cb5025 Implement coverage option
To use pass -DCMAKE_BUILD_TYPE=Debug or Asan -DCOVERAGE=ON and build as
usual, then do ninja lcov-initialize && ninja check && ninja
lcov-collect. The result will be a directory, <Builddir>/Coverage
containing lcov tracefiles, including an aggregate file gnucash.info
which you can use for further processing. It will also report an overall summary.
Note that only C/C++ files are included.

There's one more target, lcov-generate-html, that you can run after
lcov-collect. It will generate a simple website in
<Builddir>/Coverage-HTML showing coverage by source directory (the
directories in <Builddir> have coverage for generated files). Each
directory path is a clickable link to a page that shows coverage for
each source file; the filenames link to a page for each showing which
lines have been exercised.
2023-12-08 14:53:02 -08:00
John Ralls
6bc12898a8 GncDate: Remove now-superfluous base parameter. 2023-12-08 13:49:28 -08:00
John Ralls
1e289cb2b8 GncDate: Remove pointless normalize_month function.
Suggested by Sherlock.
2023-12-08 13:47:24 -08:00
John Ralls
966cef19aa Bug 799156 - normalize_struct_tm() does not normalize seconds,...
minutes, and hours correctly.

Fix proposed by Sherlock.
2023-12-08 13:45:04 -08:00
John Ralls
5005c3cac8 Merge Sherlock's 'bug799151' into stable. 2023-12-07 17:31:33 -08:00
Sherlock
ae8492d73a Update test-gnc-date.c 2023-12-07 17:31:19 -08:00
Sherlock
5a7b6e9814 Bug 799151 - gnc_date_get_last_mday () does not account for,,,
leap years correctly.
2023-12-07 17:30:08 -08:00
Sherlock
07e94b4222 Bug 799152 - normalize_reldate_tm() does not handle dates with...
months greater than 11 or less than -11 correctly.
2023-12-07 16:53:05 -08:00
John Ralls
d8dacb86b2 Bug 799143 - FTBFS on 32bit architectures
Fix misuse of GUINT_TO_POINTER in 5e09b66.
2023-11-28 01:47:12 +00:00
John Ralls
92de074e49 Bug 799144 - Date Completion is broken after 5.4 upgrade
strptime will reasonable return false for an incomplete date but it
still fills in the parts of the struct tm that it understands, so bail
out of qof_scan_date_internal when it fails only if all three fields
are present.
2023-11-26 09:23:58 -08:00
John Ralls
ed4921271c Bug 799134 - Fails to build with GCC 14 (‘find_if’ is not a member...
of ‘std’; did you mean ‘find’)
2023-11-21 15:27:04 -08:00
Christopher Lam
1d26d99ddb [gnc-budget] use std::optional<gnc_numeric> instead of bool+gnc_numeric
more expressive
2023-11-18 08:59:32 +08:00
John Ralls
dd0b72cdb5 Fix global array index out of range.
Tests must set the account type to avoid errors in xaccAccountOrder.
2023-11-17 15:20:29 -08:00
Christopher Lam
fdcb8b46bd [sixtp-dom-generators.cpp] char* must be freed 2023-11-11 12:45:57 +08:00
Christopher Lam
8f7eecd3e9 Merge branch 'icu-list-formatter' into stable #1791 2023-11-10 18:58:35 +08:00
Christopher Lam
9e47c297ba Merge branch 'plug-recurrence-to-string' into stable #1812 2023-11-07 06:28:39 +08:00
Christopher Lam
6940488d2d recurrencePeriodTypeToString and recurrenceWeekendAdjustToString g_strdup only when necessary
... for sql use only. xml use assumes they return a const char*.
2023-11-06 14:12:17 -08:00
Christopher Lam
12f4233396 recurrencePeriodTypeToString and recurrenceWeekendAdjustToString g_strdup only when necessary
... for sql use only. xml use assumes they return a const char*.
2023-11-06 17:37:17 +08:00
Adam Wight
fbc183a544 Always return an allocated gchar*
Returning the literal string will cause the caller to free unallocated
memory.
2023-11-05 23:58:01 +01:00
John Ralls
f67b53a440 Xml backend tests: Use libgnc-backend-xml-utils instead of sources.
Every test was rebuilding it except for gnc-backend-xml.cpp from
scratch, no point in that plus the Address Sanitizer needs the
definition of GncBackendXml.
2023-11-02 12:58:55 -07:00
John Ralls
fa119f8d17 Split test other 2023-11-02 12:58:55 -07:00
John Ralls
e17ba3cc00 Fix UAF in xaccFreeSplit.
xaccSplitComputeCapGains creates gains_split pointers in both the Cap Gains Split and its Income split to the original split, but the original's gains_split pointer can point to only one of them, the Cap Gains split. When the original split is freed both the Cap Gains split's and its Income split need their gains_split pointers NULLed or when it's the Income split's turn to be freed it will try to deref the dangling pointer.
2023-11-02 12:58:55 -07:00
John Ralls
2234fa433e Add Asan build type that enables the Address and UB sanitizers.
Uses generator statements instead of CMAKE_<TYPE>_FLAGS_ASAN to support multiconfig generators like Xcode.
2023-11-02 12:58:46 -07:00
Christopher Lam
d617129db8 avoid strlen where possible
if testing emptiness, test *str instead.
2023-11-01 22:43:16 +08:00
Simon Arlott
90c9aaf4cb
Bug 799108 - "Since Last Run" crashes if there are any errors creating a scheduled transaction
Pass a creation_errors list to gnc_sx_instance_model_effect_change() so
that errors creating SX can be stored, and then display them.
2023-10-21 20:39:23 +01:00
John Ralls
4592530318 Bug 799099 - Crash when trying to get quotes
The comment on gnc_pricedb_add_price says that writing to the
GNCPrice* after calling it will produce interesting results, and
calling gnc_price_commit_edit and g_object_unref both qualify, so
remove those calls and the corresponding gnc_price_begin_edit.
2023-10-20 08:46:57 -07:00
Sherlock
52f1076b30
Bug 799104 - "Asset Chart" broken 2023-10-13 16:58:54 -07:00
John Ralls
44c278a82c Fix GncDateEntry date parsing oddities.
The intent was always to default to today if the input string isn't
parsable, but two problems prevented that: First,
qof_scan_date_internal didn't check the return value of strptime and
return FALSE if it failed and second gnc_date_edit_get_date_internal
would unnecessarily munge a valid struct tm from gnc_tm_get_today_neutral.
2023-10-12 15:51:35 -07:00
John Ralls
a389e0a32e Bug 799092 - GnuCash 5.4 leaves background process running on exit
Clear the schema_hash at app shutdown via gnc_prefs_remove_registered
and make that function available to the Python bindings so that
python programs can do so too.
2023-10-02 12:31:59 -07:00
Christopher Lam
ab7ead39ca use icu::ListFormatter to combine a list strings into a string 2023-10-02 17:52:54 +08:00
Christopher Lam
d1b2368f4d Merge Yongun Seong's branch 'utest-gnc-pricedb-types' into stable #1784 2023-09-27 22:16:39 +08:00
Yongun Seong
0bd556c581
[utest-gnc-pricedb] fix test failure due to callback type mismatch 2023-09-25 15:38:06 +09:00
John Ralls
422fd0cab2 Fix misspelled/missing dist files. 2023-09-23 14:01:11 -07:00
John Ralls
776a430734 Bug 798904 - GnuCash on Windows opens a CMD window at startup.
Applied patch from bug report supplied by "Sherlock".
2023-09-22 13:21:11 -07:00
John Ralls
90b9142096 [DBI backend] Change DBI test URLs to environment variables.
From cmake configuration definitions.
2023-09-21 14:33:50 -07:00
Christopher Lam
550c43d13a Merge branch 'free-guid-string' into stable #1777 2023-09-20 07:29:16 +08:00
John Ralls
a49fd0bc09 [c++options] Correctly implement handling Fancy Date Format.
It's not a simple string.
2023-09-19 16:05:53 -07:00
Christopher Lam
8e21d3328f guid_to_string should be freed. 2023-09-19 20:31:11 +08:00
Christopher Lam
d21698f7cf [gnc-option-impl] don't leak char*
use the stack
2023-09-19 07:59:53 +08:00
Christopher Lam
55b9382ad9 [utest-gnc-backend-sql] properly clean up QofBook 2023-09-19 07:59:38 +08:00
Christopher Lam
01f27e9c53 [test-commodities] clean up commodities 2023-09-19 07:59:38 +08:00
Christopher Lam
fccf0b48c4 [utest-Account] g_free char* 2023-09-19 07:59:38 +08:00
Christopher Lam
c074b82224 [test-qofsession] plugs Account* leak 2023-09-17 08:37:09 +08:00
Christopher Lam
1ddee7dc3f [test-qofbook] plugs Account* leak 2023-09-17 08:37:04 +08:00
Christopher Lam
a81bc72fb1 [test-sx] plug some leaks 2023-09-16 08:42:42 +08:00
Christopher Lam
94211c2e57 [test-sx] plug some leaks 2023-09-16 08:42:40 +08:00
Christopher Lam
14622e7db6 [test-print-parse-amount] plug leaks 2023-09-16 05:46:46 +08:00
Christopher Lam
c44194606a [test-xml-pricedb] free a sixtp parser 2023-09-15 23:55:06 +08:00
Christopher Lam
34564ef6d0 [test-qofobject] plug some leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
8277f4d559 [test-qofbook] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
0056e5f091 [gtest-import-map] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
235e24a055 [account.cpp] ~GncImapInfo = gnc_account_imap_info_destroy 2023-09-15 23:34:43 +08:00
Christopher Lam
db77fb81a5 [test-job] plug leaks 2023-09-15 23:34:43 +08:00
Christopher Lam
a8dffb8559 [gnc-date.cpp] don't alloc tm* unless GncDateTime() succeeds
because GncDateTime() may throw an exception, in which case time will
leak. mainly leaks in test suite.
2023-09-15 23:33:47 +08:00
Christopher Lam
5a03d9798c [gnc-sx-instance-model] g_free char* 2023-09-15 23:33:47 +08:00
John Ralls
16c9957cac Bug 798925 - Python bindings: "invalid unclassed pointer...
in cast to 'QofInstance'".

The list ended up with two entries of payment_lot resulting in a
dangling reference when one of them was freed.
2023-09-11 17:40:48 -07:00
John Ralls
89360252fb Bug 798983 - Empty Orphan account appears after entering transactions in 5.3
Caused by trying to set the account on the blank split. The blank split
was present because the method used to clear the split list for the
receiving transaction in gnc_float_txn_to_txn_swap_accounts only removed
splits that belong to the transaction, and the blank split doesn't.

Adds new function xaccTransClearSplits to do a more thorough job.
Also improve the documentation for xaccSplitDestroy to better explain when
a transaction will be destroyed if it empties the split list.

 # Please enter the commit message for your
changes. Lines starting
2023-09-08 15:08:44 -07:00
Christopher Lam
7ce4198c20 rename string_to_gnc_numeric to gnc_numeric_from_string 2023-08-29 08:45:20 +08:00
Christopher Lam
c45b9736ab [gnc-numeric.cpp] parse integer + fraction; e.g."10 1/4" == 10.25 2023-08-29 08:30:30 +08:00
Geert Janssens
e2f8233e1e Bug 798950 - Bug Report: Incorrect Currency Conversion and Provider Invoice Payment Recording
- Balancing lots always involves splits in the same account. So
  the relevant number to use in the calculations is the split
  amount, not the split value.
- Additionally don't assume transactions are single-currency.
  So if amounts change, recalculate the associated values
  based on deduced exchange rates.
- Finally if the lot balancing resulted in a split to be broken up
  into two splits use conservative calculations for the new
  splits' values to avoid introducing imbalances due to
  rounding errors.
2023-08-21 16:01:27 +02:00
Mike Alexander
3aa6e60f95 fix debugging output, no functional change. 2023-08-16 00:07:56 -04:00
Christopher Lam
f8546dc4da Fix compilation error from 5781f3445b 2023-08-11 23:35:10 +08:00
John Ralls
73dec63d1d Eliminate a frequent exception in guid_from_string
By not trying to construct a GUID from an empty string.
2023-08-10 14:05:10 -07:00
John Ralls
5781f3445b SQLBackend: Use std::optional return value instead of exceptions
For wrong value type when retrieving a value from the SQL results row.

Profiling showed that most of the SQL load time was spent in handling
these exceptions, and using std::optional instead produced a > 11x
speedup (10 seconds vs. 115 seconds) when loading a large file.
2023-08-10 14:05:10 -07:00
John Ralls
a5404f6607 Improve reporting when parse_quote throws an exception.
Add more detail to the error message and pass the right value to the
gnc_error_dialog so that the error is actually displayed to the user.
2023-08-08 15:41:16 -07:00
Christopher Lam
e91752dba2 [gnc-ui-util.c] plug GList* leak
because gnc_account_get_children should have been freed.
2023-08-08 19:59:54 +08:00
Christopher Lam
fc21c55a0b [gnc-pricedb.cpp] more glib g_list uses
* use g_list_find_custom where appropriate
* also g_list_free_full and g_list_foreach
2023-08-07 08:39:07 +08:00
Christopher Lam
d89544563d Revert "[gnc-pricedb.cpp] use std::pair instead of a struct for PriceTuple"
This reverts commit 2d730e38d5.
2023-08-05 11:02:57 +08:00
Christopher Lam
2d730e38d5 [gnc-pricedb.cpp] use std::pair instead of a struct for PriceTuple 2023-08-04 20:34:07 +08:00
Christopher Lam
6b741ddf32 [gnc-pricedb.cpp] use forloop instead of do..while and while
because they're scanning GLists, and forloop is tidier than while
2023-08-04 20:33:02 +08:00
John Ralls
4d46a8191d Merge Simon Arlott's 'test-xml-save' into stable. 2023-08-03 11:05:11 -07:00
Christopher Lam
79c0fe4724 [gnc-pricedb.cpp] convert hash_table_to_list to hash_table_to_vector 2023-08-03 00:34:30 +08:00
Christopher Lam
5e09b662a1 [utest-gnc-pricedb] test gnc_pricedb_foreach_price both stable and unstable 2023-08-03 00:33:52 +08:00
Christopher Lam
040ccb79b6 [gnc-pricedb.cpp] rewrite price_list_insert more efficiently
no need for PriceListIsDuplStruct
and shortcut "return true" if price is a duplicate
2023-08-02 23:23:00 +08:00
Christopher Lam
d6b49bbc89 [utest-gnc-pricedb.c] tests gnc_pricedb_price_list_insert
especially skipping adding duplicate price
2023-08-02 23:19:20 +08:00
Simon Arlott
35bee1382d
Test loading and saving XML files with and without compression
Add new test files that are written with the latest version of GnuCash.
Test loading them, saving to compressed files, loading those compressed
files and writing to an uncompressed file. At every stage check it matches
the canonical version.
2023-07-30 19:11:57 +01:00
John Ralls
dee01706eb Merge John Ralls's 'bug798958' into stable. 2023-07-28 12:10:22 -07:00
John Ralls
cbe765c6d9 Bug 798958 - gncScrubLotLinks will infinite loop in some conditions
The conditions being containing a split from a voided transaction.
Instead of trying to destroy zero-value splits (doomed to fail in
that instance and generally rude otherwise) just remove them from
the lot list.
2023-07-27 14:46:55 -07:00
Christopher Lam
867867da53 Merge Richard Cohen branch 'fix-leaks-in-tests' into stable #1713 2023-07-24 13:09:55 +08:00
Christopher Lam
920f760dd8 Merge Richard Cohen branch 'fix-some-leaks-on-error-path' into stable #1714 2023-07-24 13:08:38 +08:00
Christopher Lam
cdc5b6a796 Merge Richard Cohen branch 'fix-test-leaks-from-get-random-string' into stable #1715 2023-07-24 13:07:40 +08:00
Christopher Lam
e841ceaaa1 [gnc-pricedb.cpp] convert to cpp 2023-07-23 15:19:43 +08:00
John Ralls
c5181180ad Fix GncOptionMultichoiceValue list tests
To conform to changes in 84eb084375.
2023-07-20 21:24:31 -07:00
Richard Cohen
a36844720d 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
2023-07-20 15:23:09 +01:00
Richard Cohen
30b47d1669 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
2023-07-20 15:23:09 +01:00
Richard Cohen
49240e9b5a 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
2023-07-20 15:23:05 +01:00
Richard Cohen
2f0c045187 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
2023-07-20 15:23:01 +01:00
Richard Cohen
394823a734 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
2023-07-20 15:22:56 +01:00
Richard Cohen
47f76fcf03 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
2023-07-20 15:22:52 +01:00
Richard Cohen
1943caee55 Fix memory leak on error path in text_to_dom_tree() 2023-07-19 10:29:06 +01:00
Richard Cohen
2640911901 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==
2023-07-19 10:21:30 +01:00
Richard Cohen
d808fddc95 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==
2023-07-19 10:21:30 +01:00
Richard Cohen
b7d278556f 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==
2023-07-19 10:21:30 +01:00
Richard Cohen
378dc40585 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)
2023-07-19 10:21:30 +01:00
Richard Cohen
69df6ea57d 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)
2023-07-19 10:21:30 +01:00
Richard Cohen
f1e889dbcb 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==
2023-07-19 10:21:30 +01:00
John Ralls
741ce55b7a Merge Richard Cohen's 'use-g-assert-true-in-tests' into stable. 2023-07-16 10:13:26 -07:00
Richard Cohen
66c5e398ae Change g_assert() -> g_assert_true() in tests
g_assert() can be compiled out, so should not be used for tests

g_assert_true was removed
to fis https://bugs.gnucash.org/show_bug.cgi?id=792008 because
g_assert_true was introduced in glib-2.38 and at the time GnuCash required
only glib-2.26. GnuCash has required glib >= 2.40 since 8acbc41c6 so
g_assert_true can be restored.
2023-07-16 10:09:12 -07:00
John Ralls
583446ade5 Merge Richard Cohen's 'declare-type-app-utils' into stable. 2023-07-16 09:48:22 -07:00
John Ralls
c405ba2cc0 Merge Richard Cohen's 'filter-online-test' into stable. 2023-07-14 15:29:59 -07:00
John Ralls
6b1941f0ed Replace yahoo_json with alphavantage in test-gnc-quotes.
Alas, poor yahoo_json. After months of valiant struggle to keep up
with Yahoo!'s moving their API around the Finance::Quote team has
abandoned it, replacing it with a screen saver. Those tend to be
unstable so use alphavantage for testing.
2023-07-14 15:15:53 -07:00
John Ralls
f2d9230299 Improve error reporting on DBI large number test failures.
There are other reasons than the original bug that can cause failure,
get some more information to understand what's going on.
2023-07-10 13:25:10 -07:00
John Ralls
a4e651ebc6 Fix test-gnc-quotes.
Forgot to change the test's date-time to neutral time.
2023-07-09 11:17:44 -07:00
John Ralls
037c2004c3 Include timezone in price-quote date diagnostic messages. 2023-07-08 16:59:16 -07:00
John Ralls
133ac88618 Bug 798982 - GetQuotes crashes if Finance::Quote returns an empty date.
Don't try to construct a date from an empty string.
2023-07-08 16:47:14 -07:00
John Ralls
e20f60361f Bug 799004 - Update of Prices attaches incorrect Date
Using a "close" time of 16:00 is a nice idea except that we don't know
what timezone it is, so it's not terribly useful. Use neutral time
instead so that the date will be right in all timezones.
2023-07-08 16:12:05 -07:00
Christopher Lam
fde47d1c7f Merge Simon Arlott branch 'gnc-numeric-to-string-leaks'into stable #1695 2023-07-08 16:01:20 +08:00
Christopher Lam
d326cca065 Bug 798998 - Job Report Not Working
GncOptions add support fo GncOptionUIType::JOB
2023-07-05 17:13:54 +08:00
Christopher Lam
59be6f4974 Merge branch 'gsettings-cpp' into stable #1682
plugs a runaway leak
2023-07-04 08:10:53 +08:00