mirror of https://github.com/python/cpython.git
* ceval.c: ifdef out the last argument passing compat hack.
* Fixed memory leaks in socket, select and sv modules: mkvalue("O", v) does INCREF(v) so if v is brand new it should be XDECREF'd
This commit is contained in:
parent
995c33a2bb
commit
6f5afc9a73
|
@ -112,6 +112,7 @@ select_select(self, args)
|
|||
{
|
||||
object *fd2obj[FD_SETSIZE];
|
||||
object *ifdlist, *ofdlist, *efdlist;
|
||||
object *ret;
|
||||
fd_set ifdset, ofdset, efdset;
|
||||
double timeout;
|
||||
struct timeval tv, *tvp;
|
||||
|
@ -168,8 +169,11 @@ select_select(self, args)
|
|||
ifdlist = set2list(&ifdset, imax, fd2obj);
|
||||
ofdlist = set2list(&ofdset, omax, fd2obj);
|
||||
efdlist = set2list(&efdset, emax, fd2obj);
|
||||
|
||||
return mkvalue("OOO", ifdlist, ofdlist, efdlist);
|
||||
ret = mkvalue("OOO", ifdlist, ofdlist, efdlist);
|
||||
XDECREF(ifdlist);
|
||||
XDECREF(ofdlist);
|
||||
XDECREF(efdlist);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -223,7 +223,10 @@ makesockaddr(addr, addrlen)
|
|||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *a = (struct sockaddr_in *) addr;
|
||||
return mkvalue("Oi", makeipaddr(a), ntohs(a->sin_port));
|
||||
object *addr = makeipaddr(a);
|
||||
object *ret = mkvalue("Oi", addr, ntohs(a->sin_port));
|
||||
XDECREF(addr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
case AF_UNIX:
|
||||
|
@ -342,7 +345,7 @@ sock_accept(s, args)
|
|||
{
|
||||
char addrbuf[256];
|
||||
int addrlen, newfd;
|
||||
object *res;
|
||||
object *sock, *addr, *res;
|
||||
if (!getnoarg(args))
|
||||
return NULL;
|
||||
if (!getsockaddrlen(s, &addrlen))
|
||||
|
@ -354,13 +357,16 @@ sock_accept(s, args)
|
|||
return socket_error();
|
||||
/* Create the new object with unspecified family,
|
||||
to avoid calls to bind() etc. on it. */
|
||||
res = mkvalue("OO", (object *) newsockobject(newfd,
|
||||
s->sock_family,
|
||||
s->sock_type,
|
||||
s->sock_proto),
|
||||
makesockaddr((struct sockaddr *) addrbuf, addrlen));
|
||||
if (res == NULL)
|
||||
sock = (object *) newsockobject(newfd,
|
||||
s->sock_family,
|
||||
s->sock_type,
|
||||
s->sock_proto);
|
||||
if (sock == NULL)
|
||||
close(newfd);
|
||||
addr = makesockaddr((struct sockaddr *) addrbuf, addrlen);
|
||||
res = mkvalue("OO", sock, addr);
|
||||
XDECREF(sock);
|
||||
XDECREF(addr);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -693,7 +699,7 @@ sock_recvfrom(s, args)
|
|||
object *args;
|
||||
{
|
||||
char addrbuf[256];
|
||||
object *buf;
|
||||
object *buf, *addr, *ret;
|
||||
int addrlen, len, n;
|
||||
if (!getintarg(args, &len))
|
||||
return NULL;
|
||||
|
@ -708,8 +714,11 @@ sock_recvfrom(s, args)
|
|||
return socket_error();
|
||||
if (resizestring(&buf, n) < 0)
|
||||
return NULL;
|
||||
return mkvalue("OO", buf,
|
||||
makesockaddr((struct sockaddr *)addrbuf, addrlen));
|
||||
addr = makesockaddr((struct sockaddr *)addrbuf, addrlen);
|
||||
ret = mkvalue("OO", buf, addr);
|
||||
XDECREF(addr);
|
||||
XDECREF(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ svc_GetFields(self, args)
|
|||
captureobject *self;
|
||||
object *args;
|
||||
{
|
||||
object *f1, *f2;
|
||||
object *f1, *f2, *ret;
|
||||
int fieldsize;
|
||||
|
||||
if (self->ob_info.format != SV_RGB8_FRAMES) {
|
||||
|
@ -136,14 +136,11 @@ svc_GetFields(self, args)
|
|||
|
||||
fieldsize = self->ob_info.width * self->ob_info.height / 2;
|
||||
f1 = newsizedstringobject((char *) self->ob_capture, fieldsize);
|
||||
if (f1 == NULL)
|
||||
return NULL;
|
||||
f2 = newsizedstringobject((char *) self->ob_capture + fieldsize, fieldsize);
|
||||
if (f2 == NULL) {
|
||||
DECREF(f1);
|
||||
return NULL;
|
||||
}
|
||||
return mkvalue("(OO)", f1, f2);
|
||||
ret = mkvalue("(OO)", f1, f2);
|
||||
XDECREF(f1);
|
||||
XDECREF(f2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static object *
|
||||
|
|
|
@ -786,13 +786,6 @@ eval_code(co, globals, locals, arg)
|
|||
break;
|
||||
|
||||
case UNPACK_ARG:
|
||||
/* Implement various compatibility hacks:
|
||||
(a) f(a,b,...) should accept f((1,2,...))
|
||||
(b) f((a,b,...)) should accept f(1,2,...)
|
||||
(c) f(self,(a,b,...)) should accept f(x,1,2,...)
|
||||
Actually, (c) is dangerous, and (b) seems
|
||||
unnecessary, but (a) can't be missed...
|
||||
*/
|
||||
{
|
||||
int n;
|
||||
if (EMPTY()) {
|
||||
|
@ -809,6 +802,12 @@ eval_code(co, globals, locals, arg)
|
|||
break;
|
||||
}
|
||||
n = gettuplesize(v);
|
||||
#ifdef COMPAT_HACKS
|
||||
/* Implement various compatibility hacks (for 0.9.4 or earlier):
|
||||
(a) f(a,b,...) accepts f((1,2,...))
|
||||
(b) f((a,b,...)) accepts f(1,2,...)
|
||||
(c) f(self,(a,b,...)) accepts f(x,1,2,...)
|
||||
*/
|
||||
if (n == 1 && oparg != 1) {
|
||||
/* Rule (a) */
|
||||
w = gettupleitem(v, 0);
|
||||
|
@ -819,7 +818,6 @@ eval_code(co, globals, locals, arg)
|
|||
n = gettuplesize(v);
|
||||
}
|
||||
}
|
||||
#ifdef COMPAT_HACKS /* Compatibility hacks no longer needed (I think) */
|
||||
else if (n != 1 && oparg == 1) {
|
||||
/* Rule (b) */
|
||||
PUSH(v);
|
||||
|
|
Loading…
Reference in New Issue