X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Frecvfrom.c;h=5cdfcae6ca152235405ef3362429553436965335;hb=51983dcb2ce9d20eb1f72d0b877e40fe0de07e87;hp=52fa3c8d4c30a38a298f844bc2e48dce91f64561;hpb=11ee0e1340f95ccb9954e522f6e003b3125eb109;p=gnulib.git diff --git a/lib/recvfrom.c b/lib/recvfrom.c index 52fa3c8d4..5cdfcae6c 100644 --- a/lib/recvfrom.c +++ b/lib/recvfrom.c @@ -1,6 +1,6 @@ /* recvfrom.c --- wrappers for Windows recvfrom function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,9 +30,9 @@ int rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from, - int *fromlen) + int *fromlen) { - int frombufsize = *fromlen; + int frombufsize = (from != NULL ? *fromlen : 0); SOCKET sock = FD_TO_SOCKET (fd); int r = recvfrom (sock, buf, len, flags, from, fromlen); @@ -41,7 +41,7 @@ rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from, /* Winsock recvfrom() only returns a valid 'from' when the socket is connectionless. POSIX gives a valid 'from' for all types of sockets. */ - else if (*fromlen == frombufsize) + else if (from != NULL && *fromlen == frombufsize) rpl_getpeername (fd, from, fromlen); return r;