pidgin: c1d44992: (Slightly modified) patch from fqueze to...

datallah at pidgin.im datallah at pidgin.im
Mon Dec 1 21:10:33 EST 2008


-----------------------------------------------------------------
Revision: c1d44992f600877e08d67a35323d16fcacff92de
Ancestor: 36b7c4f70a6a951c061811d2118a395ee59b7e06
Author: datallah at pidgin.im
Date: 2008-12-02T02:06:19
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c1d44992f600877e08d67a35323d16fcacff92de

Modified files:
        libpurple/win32/libc_interface.c

ChangeLog: 

(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

-------------- next part --------------
============================================================
--- libpurple/win32/libc_interface.c	957d7f22e4d82d08e6067d60007f406e91bb4325
+++ libpurple/win32/libc_interface.c	238013cbcda3082f3bde394d19ae41f596738a60
@@ -351,6 +351,11 @@ int wpurple_read(int fd, void *buf, unsi
 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 *bu
 
 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 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();


More information about the Commits mailing list