summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-08-05 16:51:05 (GMT)
committerGuido van Rossum <guido@python.org>1997-08-05 16:51:05 (GMT)
commit83f9ad8399a7b199263ea1522a8d599d6dea6eb0 (patch)
tree80b97fde95182b742b52264a7c18ff848e491da9
parentd6615ab30c5155b746aaef1565835c962d16bae3 (diff)
downloadcpython-83f9ad8399a7b199263ea1522a8d599d6dea6eb0.zip
cpython-83f9ad8399a7b199263ea1522a8d599d6dea6eb0.tar.gz
cpython-83f9ad8399a7b199263ea1522a8d599d6dea6eb0.tar.bz2
Fix bug in comparing function objects detected by Sjoerd:
SystemError: bad argument to internal function caused by comparing NULL pointer default args.
-rw-r--r--Objects/funcobject.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 53c926f..be67259 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -182,9 +182,15 @@ func_compare(f, g)
int c;
if (f->func_globals != g->func_globals)
return (f->func_globals < g->func_globals) ? -1 : 1;
- c = PyObject_Compare(f->func_defaults, g->func_defaults);
- if (c != 0)
- return c;
+ if (f->func_defaults != g->func_defaults) {
+ if (f->func_defaults == NULL)
+ return -1;
+ if (g->func_defaults == NULL)
+ return 1;
+ c = PyObject_Compare(f->func_defaults, g->func_defaults);
+ if (c != 0)
+ return c;
+ }
return PyObject_Compare(f->func_code, g->func_code);
}