summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-01-10 23:39:33 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-01-10 23:39:33 +0000
commit16de50671c7ad77f2acb4ca19d8806aad0490f03 (patch)
tree58a6ea3833468a5f79023de06a39efa7b35dce65 /src
parentded707de84a7b1f36a395299ff945c2b2e069bff (diff)
downloadskalibs-16de50671c7ad77f2acb4ca19d8806aad0490f03.tar.xz
Without a segfault in unixmessage_sender_free, please.v2.2.0.0
Diffstat (limited to 'src')
-rw-r--r--src/libunixonacid/unixmessage_sender_free.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c
index 965b1a7..6ef0f42 100644
--- a/src/libunixonacid/unixmessage_sender_free.c
+++ b/src/libunixonacid/unixmessage_sender_free.c
@@ -9,15 +9,18 @@
void unixmessage_sender_free (unixmessage_sender_t *b)
{
- unsigned int i = genalloc_s(diuint, &b->offsets)[b->head].right ;
unsigned int n = genalloc_len(int, &b->fds) ;
- for (; i < n ; i++)
+ if (n)
{
- register int fd = genalloc_s(int, &b->fds)[i] ;
- if (fd < 0) fd_close(-(fd+1)) ;
+ unsigned int i = genalloc_s(diuint, &b->offsets)[b->head].right ;
+ for (; i < n ; i++)
+ {
+ register int fd = genalloc_s(int, &b->fds)[i] ;
+ if (fd < 0) fd_close(-(fd+1)) ;
#ifdef SKALIBS_HASANCILAUTOCLOSE
- else fd_close(fd) ;
+ else fd_close(fd) ;
#endif
+ }
}
genalloc_free(diuint, &b->offsets) ;
genalloc_free(int, &b->fds) ;