Commit Graph

1111 Commits

Author SHA1 Message Date
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
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
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
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
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
8f7eecd3e9 Merge branch 'icu-list-formatter' into stable #1791 2023-11-10 18:58:35 +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
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
Sherlock
52f1076b30
Bug 799104 - "Asset Chart" broken 2023-10-13 16:58:54 -07:00