Commit Graph

3 Commits

Author SHA1 Message Date
Patrick Steinhardt
95fa38802f pqueue: resolve possible NULL pointer dereference
The `git_pqueue` struct allows being fixed in its total number of
entries. In this case, we simply throw away items that are
inserted into the priority queue by examining wether the new item
to be inserted has a higher priority than the previous smallest
one.

This feature somewhat contradicts our pqueue implementation in
that it is allowed to not have a comparison function. In fact, we
also fail to check if the comparison function is actually set in
the case where we add a new item into a fully filled fixed-size
pqueue.

As we cannot determine which item is the smallest item in absence
of a comparison function, we fix the `NULL` pointer dereference
by simply dropping all new items which are about to be inserted
into a full fixed-size pqueue.
2016-10-28 16:19:24 +02:00
Russell Belfer
5302a88538 Fix pqueue sort boundary condition bug
If the pqueue comparison fn returned just 0 or 1 (think "a<b")
then the sort order of returned items could be wrong because there
was a "< 0" that really needed to be "<= 0".  Yikes!!!
2014-03-12 11:21:55 -07:00
Russell Belfer
af4bc6615d Add some priority queue tests
I forgot that I wrote some tests for the new priority queue code.
2014-02-03 21:04:40 -08:00