Closed oschwald closed 5 years ago
There are quite a few places where unsigned integers are compared to 0 or negative numbers.
cache->p_cur
is unsigned and gets assigned-1
, relying on the underflow behavior. I am not sure if this is intentional, but some of the later comparisons look suspicious if it is.
I'm not sure how I missed this, certainly I'm surprised that I never saw any warnings from the compiler about it.
Perhaps a better idea would be to do something like:
#define NOPAGE ((MU32)~0)
And then use that everywhere instead of -1. I think it would be exactly the same result, but clearer code.
Which comparisons look suspicious to you, I'll take a closer look.
Some of the sanity checks look suspect, e.g., it->p_cur
has a similar issue and there are checks like:
I didn't dig into it though.
Thanks for merging so quickly and doing a release!
While trying to sort out a memory corruption issue, I noticed the following from Valgrind:
I also noticed some memory leaks and unused variables that I fixed.
There are quite a few places where unsigned integers are compared to 0 or negative numbers.
cache->p_cur
is unsigned and gets assigned-1
, relying on the underflow behavior. I am not sure if this is intentional, but some of the later comparisons look suspicious if it is.