Skip to content

Conversation

@fanzhoulll
Copy link

The original program does not work with parameter -n.

Note the mSettings->mAmount is an unsigned type. We need to take care of the case when mSettings->mAmount - currLen leads to overflow.

@hselasky
Copy link

Is this happening on 32-bit only platforms? I don't see an issue with 64-bit platforms.

if ( !mMode_Time ) {
mSettings->mAmount -= currLen;
if (mSettings->mAmount >= currLen) {
mSettings->mAmount -= currLen;
Copy link

@hselasky hselasky Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix indention style here.

Also, mAmount should only be compared for zero, because it is unsigned!

0 >= mSettings->mAmount

Should probably be:

0 == mSettings->mAmount

@hselasky
Copy link

I see now:
mAmount is declared like an unsigned variable
uintmax_t mAmount;

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