changeset 24578:ef70bcdae73f

(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs. I modified it to use g_return_val_if_reached() because we need to track down and fix the places where invalid fds are being used. Fixes #7608
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 02 Dec 2008 02:06:19 +0000
parents 3cae90524840
children dea69e5e3427
files libpurple/win32/libc_interface.c
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/win32/libc_interface.c	Mon Dec 01 23:58:58 2008 +0000
+++ b/libpurple/win32/libc_interface.c	Tue Dec 02 02:06:19 2008 +0000
@@ -351,6 +351,11 @@
 int wpurple_read(int fd, void *buf, unsigned int size) {
 	int ret;
 
+	if (fd < 0) {
+		errno = EBADF;
+		g_return_val_if_reached(-1);
+	}
+
 	if(wpurple_is_socket(fd)) {
 		if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) {
 			errno = WSAGetLastError();
@@ -391,6 +396,11 @@
 
 int wpurple_write(int fd, const void *buf, unsigned int size) {
 
+	if (fd < 0) {
+		errno = EBADF;
+		g_return_val_if_reached(-1);
+	}
+
 	if(wpurple_is_socket(fd))
 		return wpurple_send(fd, buf, size, 0);
 	else
@@ -413,6 +423,11 @@
 int wpurple_close(int fd) {
 	int ret;
 
+	if (fd < 0) {
+		errno = EBADF;
+		g_return_val_if_reached(-1);
+	}
+
 	if( wpurple_is_socket(fd) ) {
 		if( (ret = closesocket(fd)) == SOCKET_ERROR ) {
 			errno = WSAGetLastError();