summaryrefslogtreecommitdiff
path: root/python/modules/cquoting.c
diff options
context:
space:
mode:
authorMarko Kreen2008-12-29 16:43:27 +0000
committerMarko Kreen2008-12-29 16:43:27 +0000
commitc34bb9e85e10d74324be232e270f948249d9623b (patch)
tree19f3c36eb8cc07d67b600cae4e78a76ca76c6b96 /python/modules/cquoting.c
parentc2853ef25cc425ca6cfb2716dea1d56623bdcc34 (diff)
Fix cquoting crash with Decimal() type.
Seems there can be types which have buffer operations struct, but no function pointers. So check also for called functions.
Diffstat (limited to 'python/modules/cquoting.c')
-rw-r--r--python/modules/cquoting.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/modules/cquoting.c b/python/modules/cquoting.c
index 42844ca2..eb518a3e 100644
--- a/python/modules/cquoting.c
+++ b/python/modules/cquoting.c
@@ -130,8 +130,10 @@ static Py_ssize_t get_buffer(PyObject *obj, unsigned char **buf_p, PyObject **tm
/* try to get buffer */
bfp = obj->ob_type->tp_as_buffer;
- if (bfp && bfp->bf_getsegcount(obj, NULL) == 1)
- return bfp->bf_getreadbuffer(obj, 0, (void**)buf_p);
+ if (bfp && bfp->bf_getsegcount && bfp->bf_getreadbuffer) {
+ if (bfp->bf_getsegcount(obj, NULL) == 1)
+ return bfp->bf_getreadbuffer(obj, 0, (void**)buf_p);
+ }
/*
* Not a string-like object, run str() or it.