More safety around ldb_dn C functions in python bindings.
authorAndrew Bartlett <abartlet@samba.org>
Wed, 19 Mar 2008 00:11:55 +0000 (11:11 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 19 Mar 2008 00:11:55 +0000 (11:11 +1100)
Ensure that the ldb python binding 'TypeError dn not set' errors are
not in the SWIG wrapper's use of ldb functions, put some more error
checks in.

Andrew Bartlett
(This used to be commit 8d4c831184cff8bca85daf6cc711b189b5cf3a47)

source4/lib/ldb/ldb.i

index bd41e1e23e6e1e116bdf098cf93f60a784ffd45e..b0723a8ecde7d47e01912bd628d0f68305352737 100644 (file)
@@ -257,15 +257,19 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
     int ret;
     struct ldb_dn *odn;
     if (ldb_ctx != NULL && PyString_Check(object)) {
-        *dn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
-       if (!*dn) {
+        odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
+       if (!odn) {
                return SWIG_ERROR;
        }
+       *dn = odn;
         return 0;
     }
     ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn, 
                            SWIG_POINTER_EXCEPTION);
     *dn = ldb_dn_copy(mem_ctx, odn);
+    if (odn && !*dn) {
+       return SWIG_ERROR;
+    }
     return ret;
 }