summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-10-04 13:30:17 +0000
committerAndrew M. Kuchling <amk@amk.ca>2006-10-04 13:30:17 +0000
commit589f333dfae51f7a1b59e87935b84daebc968083 (patch)
tree6897a1372637238b56122eff7ee4cc6bdfab902e
parentd3499a30713c972e293ee677efe7b37a41efb4db (diff)
downloadcpython-git-589f333dfae51f7a1b59e87935b84daebc968083.tar.gz
[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]
-rw-r--r--Modules/_sre.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 6da6de5482..a1c596a0d6 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;