-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix xaccTransGetTxnType: avoid returning TXN_TYPE_LINK incorrectly
A TXN_TYPE_PAYMENT will have non-APAR splits; a TXN_TYPE_LINK will not have non-APAR splits. This bug manifests as a regular TXN_TYPE_PAYMENT transaction being later voided being incorrectly changed to TXN_TYPE_LINK.
- Loading branch information
1 parent
853791c
commit 4a60e01
Showing
2 changed files
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW the
xaccTransUnvoid
does not seem important in this unit test. However without this line, the teardown function segfaults.4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segfaults on what?
4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what's happening is that teardown destroys the invoice at line 94, which frees the lot but doesn't remove the split's copy of the pointer. Line 97 destroys the account containing the split, which eventually calls xaccSplitCommitEdit. That wants its lot* to remove the split, but the lot has been freed and you get the crash. I guess that xaccSplitUnvoid is getting the split removed and the split's lot* nulled before cleanup, avoiding the crash.
Simplest fix would be to destroy the invoice at the end instead of the beginning of teardown.
4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the best fix would be to let RAII do it lol
4a60e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but using RAII requires a complete re-implementation of the engine including creating an actual memory model. We need to first get rid of QofQuery and all of the crap that goes along with it.