From: Guido van Rossum Date: Thu, 26 Nov 1992 10:30:26 +0000 (+0000) Subject: * classobject.c: in instance_lenth, test result of call_object X-Git-Tag: v0.9.8~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d014ea6b5efbfb3d143fc8aacf8bee733cf4c8f0;p=thirdparty%2FPython%2Fcpython.git * classobject.c: in instance_lenth, test result of call_object for exception before using it. Fixed a few other places where the outcome of calling sq_length wasn't tested for exceptions (bltinmodule.c, ceval.c). --- diff --git a/Objects/classobject.c b/Objects/classobject.c index e3b12c68f6e0..0661e810c86e 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -324,6 +324,8 @@ instance_length(inst) return -1; res = call_object(func, (object *)NULL); DECREF(func); + if (res == NULL) + return -1; if (is_intobject(res)) { outcome = getintvalue(res); if (outcome < 0) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a6e02bed2d6b..85fd58ecee58 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -412,6 +412,8 @@ min_max(v, sign) return NULL; } n = (*sq->sq_length)(v); + if (n < 0) + return NULL; if (n == 0) { err_setstr(ValueError, "min() or max() of empty sequence"); return NULL; diff --git a/Python/ceval.c b/Python/ceval.c index d3a732a62ee8..86ee6cfc23fe 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1881,6 +1881,8 @@ loop_subscript(v, w) } i = getintvalue(w); n = (*sq->sq_length)(v); + if (n < 0) + return NULL; /* Exception */ if (i >= n) return NULL; /* End of loop */ return (*sq->sq_item)(v, i);