From 1a7855309322a7dcbf7d7ee3356fe693ffb5b336 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 17 Jul 1998 20:19:48 +0000 Subject: [PATCH] Add test for failure of the getattr call in pcre_expand() -- it used to core dump if the first argument did not have a "group" attribute. --- Modules/pcremodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/pcremodule.c b/Modules/pcremodule.c index 60b702993b2..f8bde043604 100644 --- a/Modules/pcremodule.c +++ b/Modules/pcremodule.c @@ -512,6 +512,10 @@ PyPcre_expand(self, args) { PyObject *r, *tuple, *result; r=PyObject_GetAttrString(match_obj, "group"); + if (r == NULL) { + Py_DECREF(results); + return NULL; + } tuple=PyTuple_New(1); Py_INCREF(value); PyTuple_SetItem(tuple, 0, value);