summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@mns.spb.ru>2010-09-19 13:53:21 +0400
committerJelmer Vernooij <jelmer@samba.org>2010-09-19 09:31:20 -0700
commit277a1b229cf1b456560a50d021e2eaf2158e5134 (patch)
tree1098dfcb844e84aee2eb4d12f0a9d6ede88f5d4b /lib
parentc4b1971259638875317aa991b6a119b668ac03a8 (diff)
downloadsamba-277a1b229cf1b456560a50d021e2eaf2158e5134.tar.gz
pytdb: Fix repr segfault for internal db
The problem was tdb->name is NULL for TDB_INTERNAL databases, and so it was crashing ... #0 0xb76944f3 in strlen () from /lib/i686/cmov/libc.so.6 #1 0x0809862b in PyString_FromFormatV (format=0xb72b6a26 "Tdb('%s')", vargs=0xbfc26a94 "") at ../Objects/stringobject.c:211 #2 0x08098888 in PyString_FromFormat (format=0xb72b6a26 "Tdb('%s')") at ../Objects/stringobject.c:358 #3 0xb72b65f2 in tdb_object_repr (self=0xb759e060) at ./pytdb.c:439 Cc: 597089@bugs.debian.org Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/pytdb.c4
-rw-r--r--lib/tdb/python/tests/simple.py8
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 58db1a8a6db..d904e47e830 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -409,7 +409,9 @@ static PyGetSetDef tdb_object_getsetters[] = {
static PyObject *tdb_object_repr(PyTdbObject *self)
{
- return PyString_FromFormat("Tdb('%s')", tdb_name(self->ctx));
+ return PyString_FromFormat("Tdb('%s')",
+ (tdb_get_flags(self->ctx) & TDB_INTERNAL) ? "<internal>"
+ : tdb_name(self->ctx));
}
static void tdb_object_dealloc(PyTdbObject *self)
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 5db824753b1..258a486f91a 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -28,6 +28,14 @@ class CloseTdbTests(TestCase):
self.tdb.close()
+class InternalTdbTests(TestCase):
+ def test_repr(self):
+ self.tdb = tdb.Tdb("whatever", tdb_flags=tdb.INTERNAL)
+
+ # repr used to crash on internal db
+ self.assertEquals(repr(self.tdb), "Tdb('<internal>')")
+
+
class SimpleTdbTests(TestCase):
def setUp(self):