mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
winnet.c: improve 64-bit-cleanness in cmpfortree.
Commit f2e61275f
converted the integer casts in cmpforsearch to
uintptr_t from unsigned long. But it left the companion function
cmpfortree alone, presumably on the grounds that the compiler didn't
report a warning for that one.
But those two functions (cmpfortree and cmpforsearch) are used with
the same tree234, so they're supposed to implement the same sorting
criterion. And the thing they're actually comparing, namely the
Windows API typedef SOCKET, is a pointer-sized integer. So there was a
latent bug here in which cmpforsearch was comparing all 64 bits of the
pointer, while cmpfortree was only comparing the low-order 32.
This commit is contained in:
parent
6f4083e682
commit
50853ddcc3
@ -124,7 +124,7 @@ static tree234 *sktree;
|
|||||||
static int cmpfortree(void *av, void *bv)
|
static int cmpfortree(void *av, void *bv)
|
||||||
{
|
{
|
||||||
NetSocket *a = (NetSocket *)av, *b = (NetSocket *)bv;
|
NetSocket *a = (NetSocket *)av, *b = (NetSocket *)bv;
|
||||||
unsigned long as = (unsigned long) a->s, bs = (unsigned long) b->s;
|
uintptr_t as = (uintptr_t) a->s, bs = (uintptr_t) b->s;
|
||||||
if (as < bs)
|
if (as < bs)
|
||||||
return -1;
|
return -1;
|
||||||
if (as > bs)
|
if (as > bs)
|
||||||
|
Loading…
Reference in New Issue
Block a user