diff Modules/socketmodule.c @ 3091:7ddfb629ac3f legacy-trunk

plug some leaks
author Guido van Rossum <guido@python.org>
date Wed, 13 Sep 1995 18:39:47 +0000
parents 37c48fde61b8
children 9bd1e41d6b11
line wrap: on
line diff
--- a/Modules/socketmodule.c	Wed Sep 13 18:39:04 1995 +0000
+++ b/Modules/socketmodule.c	Wed Sep 13 18:39:47 1995 +0000
@@ -779,8 +779,10 @@
 	Py_BEGIN_ALLOW_THREADS
 	n = recv(s->sock_fd, PyString_AsString(buf), len, flags);
 	Py_END_ALLOW_THREADS
-	if (n < 0)
+	if (n < 0) {
+		Py_DECREF(buf);
 		return PySocket_Err();
+	}
 	if (_PyString_Resize(&buf, n) < 0)
 		return NULL;
 	return buf;
@@ -814,8 +816,10 @@
 		     (struct sockaddr *)addrbuf, &addrlen);
 #endif
 	Py_END_ALLOW_THREADS
-	if (n < 0)
+	if (n < 0) {
+		Py_DECREF(buf);
 		return PySocket_Err();
+	}
 	if (_PyString_Resize(&buf, n) < 0)
 		return NULL;
 	addr = makesockaddr((struct sockaddr *)addrbuf, addrlen);