Merge pull request #705 from laserswald/fix-arithmetic-exception-filenos

Prevent arithmetic exception when spawning lots of commands
This commit is contained in:
Alex Shinn 2020-09-19 13:20:39 +09:00 committed by GitHub
commit 7448c22466
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

2
sexp.c
View file

@ -1806,6 +1806,8 @@ static sexp* sexp_fileno_cell(sexp ctx, sexp vec, int fd) {
if (!sexp_vectorp(vec))
return NULL;
len = sexp_vector_length(vec);
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)
if (!sexp_ephemeronp(data[cell])