mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-15 17:07:34 +02:00
check for wrapping to negative in hash lookup of cell (issue #735)
Without this chibi can crash after 129 open file descriptors. Note the bug referenced would also indirectly be fixed if process->string-list properly closed its ports, but we shouldn't rely on that.
This commit is contained in:
parent
13a2a562d9
commit
7ea15f3810
1 changed files with 3 additions and 1 deletions
4
sexp.c
4
sexp.c
|
@ -1809,7 +1809,9 @@ static sexp* sexp_fileno_cell(sexp ctx, sexp vec, int fd) {
|
|||
if (len == 0)
|
||||
return NULL;
|
||||
data = sexp_vector_data(vec);
|
||||
for (i = 0, cell = (fd * FNV_PRIME) % len; i < len; i++, cell=(cell+1)%len)
|
||||
cell = (fd * FNV_PRIME) % len;
|
||||
if (cell < 0) cell += len;
|
||||
for (i = 0; i < len; i++, cell=(cell+1)%len)
|
||||
if (!sexp_ephemeronp(data[cell])
|
||||
|| (sexp_filenop(sexp_ephemeron_key(data[cell]))
|
||||
&& sexp_fileno_fd(sexp_ephemeron_key(data[cell])) == fd))
|
||||
|
|
Loading…
Add table
Reference in a new issue