Eg, Tcl passes -1 to close (!)
#0 0x00007f62949883ca in close (fd=-1) at udp-preload.c:207
#1 0x00007f6294719362 in Tcl_FinalizeNotifier () from /usr/lib/x86_64-linux-gnu/libtcl8.6.so
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
static int tablesz;
static fdinfo *lookup(int fd) {
static int tablesz;
static fdinfo *lookup(int fd) {
- if (fd>=tablesz) return 0;
+ if (fd<0 || fd>=tablesz) return 0;
+ if (fd>=0 && fd<tablesz) {
free(table[fd]);
table[fd]=0;
}
free(table[fd]);
table[fd]=0;
}