Fixing UB in hsearch
Referenced by issue: https://github.com/tinyproxy/tinyproxy/issues/470
This commit is contained in:
parent
3764b85514
commit
89c2d22076
@ -82,7 +82,13 @@ static int resize(struct htab *htab, size_t nel)
|
|||||||
size_t i, j;
|
size_t i, j;
|
||||||
struct elem *e, *newe;
|
struct elem *e, *newe;
|
||||||
struct elem *oldtab = htab->elems;
|
struct elem *oldtab = htab->elems;
|
||||||
struct elem *oldend = htab->elems + htab->mask + 1;
|
size_t offset = 1;
|
||||||
|
if (htab->elems)
|
||||||
|
offset += htab->elems;
|
||||||
|
if (htab->mask)
|
||||||
|
offset += htab->mask;
|
||||||
|
|
||||||
|
struct elem *oldend = offset;
|
||||||
|
|
||||||
if (nel > MAXSIZE)
|
if (nel > MAXSIZE)
|
||||||
nel = MAXSIZE;
|
nel = MAXSIZE;
|
||||||
|
Loading…
Reference in New Issue
Block a user