Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find a small bug here #21

Open
No-47 opened this issue Oct 23, 2020 · 2 comments
Open

find a small bug here #21

No-47 opened this issue Oct 23, 2020 · 2 comments

Comments

@No-47
Copy link

No-47 commented Oct 23, 2020

图片
look at this picture above plz...we know that the type of "rest ", "data.blockSize" and "requiredSize" is std::size_t.
However, std::size_t is unsigned __int64. So they are unsigned. if you do "rest = affectedNode->data.blockSize - requiredSize", it will always get a value greater than zero. when "data.blockSize < requiredSize", it will be a great trouble ("rest" will be a Huge unsigned number).....
a better way is:
图片

@No-47 No-47 changed the title find some small bug here find a small bug here Oct 23, 2020
@AnthonySoler
Copy link

Hello

If the Find method returned a result (affectedNode), it means that affectedNode->data.blockSize is always greater or equals to requiredSize. Otherwise, there is not enough memory (and you may want to return nullptr)

However, in this piece of code, the if(rest > 0) may be replaced by if(rest > sizeof(Node)) since we need at least the room for a Node.

Have a good day,

@bharsaklemukesh975
Copy link

can I do this as my first open source issue?

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

No branches or pull requests

3 participants