From 9b87ff70bea433f7efbfa95e8998c00ce150cabe Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Sat, 8 Dec 2007 23:00:37 +0000 Subject: [PATCH] (readv, writev) [_WIN32]: Set errno to ENOMEM when unable memory. --- src/lib/w32/posixio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/w32/posixio.c b/src/lib/w32/posixio.c index e6fe7f30..8a5f4b7b 100644 --- a/src/lib/w32/posixio.c +++ b/src/lib/w32/posixio.c @@ -520,8 +520,10 @@ readv(int fd, const struct iovec *iov, int iovcnt) } buffer = malloc(total_bytes); - if (buffer == NULL && total_bytes != 0) + if (buffer == NULL && total_bytes != 0) { + errno = ENOMEM; return -1; + } bytes_read = posix_read(fd, buffer, total_bytes); if (bytes_read <= 0) { @@ -573,8 +575,10 @@ writev(int fd, const struct iovec *iov, int iovcnt) total_bytes += iov[i].iov_len; buffer = malloc(total_bytes); - if (buffer == NULL && total_bytes != 0) + if (buffer == NULL && total_bytes != 0) { + errno = ENOMEM; return -1; + } buffer_location = buffer; for (i = 0; i < iovcnt; i++) {