]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport r51225 | neal.norwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 4 Oct 2006 13:30:17 +0000 (13:30 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 4 Oct 2006 13:30:17 +0000 (13:30 +0000)
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

index 6da6de54828d760958f6768a8024a59064268295..a1c596a0d63cebc213a40c3e8e00d99684d69692 100644 (file)
@@ -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;