diff options
-rw-r--r-- | Modules/selectmodule.c | 8 | ||||
-rw-r--r-- | Modules/socketmodule.c | 31 | ||||
-rw-r--r-- | Modules/svmodule.c | 13 | ||||
-rw-r--r-- | Python/ceval.c | 14 |
4 files changed, 37 insertions, 29 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index be2b062..99a9213 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -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; } diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index c72c9fd..2a0e291 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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; } diff --git a/Modules/svmodule.c b/Modules/svmodule.c index 0d14473..bbdbf33 100644 --- a/Modules/svmodule.c +++ b/Modules/svmodule.c @@ -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 * diff --git a/Python/ceval.c b/Python/ceval.c index b28f17c..727bc0c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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); |