Skip to content

Fix code bugs caught by PVS-Studio#56

Merged
Gumball2415 merged 4 commits intoDn-Programming-Core-Management:devfrom
nyanpasu64:fix-ub
Sep 11, 2021
Merged

Fix code bugs caught by PVS-Studio#56
Gumball2415 merged 4 commits intoDn-Programming-Core-Management:devfrom
nyanpasu64:fix-ub

Conversation

@nyanpasu64
Copy link
Copy Markdown
Collaborator

It compiles, but I haven't fully tested that all the fixes are correct.

Outdated/incomplete explanations are at https://docs.google.com/document/d/1XZvoRhS5ucHrwnDav2-tlTOL9g02x0QRRBRIH9J3gpo/edit?usp=sharing.

stChannelState::Echo[3] was uninitialized prior to this fix.
stChannelState::Echo is read by CFamiTrackerDoc::RetrieveSoundState(),
a strange non-const function called upon recalling or retrieving
channel state (eg. beginning playback). The algorithm is complex
and I don't understand it. I'm just "fixing" it.

The algorithm is strange and complex
m_iFrame - other.m_iFrame is intended to produce a negative result.
In the old code, it produced a very large unsigned integer (bad),
but it got casted to a negative signed integer upon * or %,
so the code was merely unclear but not wrong.
Anyway I've cleaned it up (at the cost of verbosity).
@nyanpasu64 nyanpasu64 changed the base branch from master to dev September 10, 2021 11:54
@nyanpasu64
Copy link
Copy Markdown
Collaborator Author

not sure what bugs i failed to patch, but might as well push what's fixed so far

@nyanpasu64 nyanpasu64 marked this pull request as ready for review September 10, 2021 11:54
@Gumball2415 Gumball2415 merged commit 49ed9ed into Dn-Programming-Core-Management:dev Sep 11, 2021
@nyanpasu64 nyanpasu64 deleted the fix-ub branch September 14, 2021 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants