From 589f333dfae51f7a1b59e87935b84daebc968083 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Wed, 4 Oct 2006 13:30:17 +0000 Subject: [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] --- Modules/_sre.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_sre.c b/Modules/_sre.c index 6da6de5..a1c596a 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; -- cgit v0.12