]> granicus.if.org Git - python/commitdiff
Get rid of obsolete allowbroadcast().
authorGuido van Rossum <guido@python.org>
Tue, 11 Jun 1996 18:35:24 +0000 (18:35 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Jun 1996 18:35:24 +0000 (18:35 +0000)
Avoid core dumps in resizestring().

Modules/socketmodule.c

index 5b971f81e64e720883c6008d466c2c3fd09eab53..b77bdac3d50532e18ccadd6264c49f79113fb59c 100644 (file)
@@ -471,27 +471,6 @@ BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args)
 }
 
 
-#if 0
-/* s.allowbroadcast() method */
-/* XXX obsolete -- will disappear in next release */
-
-static PyObject *
-BUILD_FUNC_DEF_2(PySocketSock_allowbroadcast,PySocketSockObject *,s, PyObject *,args)
-{
-       int flag;
-       int res;
-       if (!PyArg_Parse(args, "i", &flag))
-               return NULL;
-       res = setsockopt(s->sock_fd, SOL_SOCKET, SO_BROADCAST,
-                        (ANY *)&flag, sizeof flag);
-       if (res < 0)
-               return PySocket_Err();
-       Py_INCREF(Py_None);
-       return Py_None;
-}
-#endif
-
-
 /* s.setblocking(1 | 0) method */
 
 static PyObject *
@@ -789,7 +768,7 @@ BUILD_FUNC_DEF_2(PySocketSock_recv,PySocketSockObject *,s, PyObject *,args)
                Py_DECREF(buf);
                return PySocket_Err();
        }
-       if (_PyString_Resize(&buf, n) < 0)
+       if (n != len && _PyString_Resize(&buf, n) < 0)
                return NULL;
        return buf;
 }
@@ -826,7 +805,7 @@ BUILD_FUNC_DEF_2(PySocketSock_recvfrom,PySocketSockObject *,s, PyObject *,args)
                Py_DECREF(buf);
                return PySocket_Err();
        }
-       if (_PyString_Resize(&buf, n) < 0)
+       if (n != len && _PyString_Resize(&buf, n) < 0)
                return NULL;
        addr = makesockaddr((struct sockaddr *)addrbuf, addrlen);
        ret = Py_BuildValue("OO", buf, addr);