fix descriptor leak in iob_addfile_close if the range was 0 (oops)

master
leitner 20 years ago
parent 1205a3d38f
commit 11da04b651

@ -8,6 +8,7 @@
document that the iob_write callback should limit itself
fix mmap_shared
add iob_free, add man pages for iob_free and iob_reset
fix descriptor leak in iob_addfile_close if the range was 0 (oops)
0.21:
errno cleanup and man page updates (Rolf Eike Beer)

@ -1,8 +1,12 @@
#include "iob_internal.h"
int iob_addbuf_internal(io_batch* b,const void* buf,uint64 n,int _free) {
iob_entry* e=array_allocate(&b->b,sizeof(iob_entry),
array_length(&b->b,sizeof(iob_entry)));
iob_entry* e;
if (!n) {
if (_free) free(buf);
return 1;
}
e=array_allocate(&b->b,sizeof(iob_entry),array_length(&b->b,sizeof(iob_entry)));
if (!e) return 0;
e->type=_free?FROMBUF_FREE:FROMBUF;
e->fd=-1;

@ -2,7 +2,10 @@
int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n) {
iob_entry* e;
if (n==0) return 1;
if (n==0) {
io_close(fd);
return 1;
}
io_fd(fd);
e=array_allocate(&b->b,sizeof(iob_entry),
array_length(&b->b,sizeof(iob_entry)));

Loading…
Cancel
Save