From: Andrew M. Kuchling Date: Wed, 4 Oct 2006 13:30:17 +0000 (+0000) Subject: [Backport r51225 | neal.norwitz] X-Git-Tag: v2.4.4c1~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=589f333dfae51f7a1b59e87935b84daebc968083;p=thirdparty%2FPython%2Fcpython.git [Backport r51225 | neal.norwitz] Try to handle a malloc failure. I'm not entirely sure this is correct. There might be something else we need to do to handle the exception. Klocwork # 212-213 [I think this needs more work; a malloc() failure will cause a match to fail, but nothing raises MemoryError. I'll work on this on the trunk and backport. --amk] --- diff --git a/Modules/_sre.c b/Modules/_sre.c index 6da6de54828d..a1c596a0d63c 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1162,6 +1162,9 @@ entrance: /* install new repeat context */ ctx->u.rep = (SRE_REPEAT*) malloc(sizeof(*ctx->u.rep)); + /* XXX(nnorwitz): anything else we need to do on error? */ + if (!ctx->u.rep) + RETURN_FAILURE; ctx->u.rep->count = -1; ctx->u.rep->pattern = ctx->pattern; ctx->u.rep->prev = state->repeat;