]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pyldb: add a macro to free when raising exceptions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 21 Feb 2024 22:19:30 +0000 (11:19 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 29 Feb 2024 04:01:40 +0000 (04:01 +0000)
We often forget.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.h

index 2d354422cdb61af265c2cb40ea3dbadc83e8e9fe..45637b76691f3637640db803e341af70be74efb2 100644 (file)
@@ -110,7 +110,15 @@ typedef struct {
        } \
 } while(0)
 
-/* Picked out of thin air. To do this properly, we should probably have some part of the 
+#define PyErr_LDB_ERROR_IS_ERR_RAISE_FREE(err,ret,ldb,mem_ctx) do {    \
+       if (ret != LDB_SUCCESS) { \
+               PyErr_SetLdbError(err, ret, ldb); \
+               TALLOC_FREE(mem_ctx);             \
+               return NULL; \
+       } \
+} while(0)
+
+/* Picked out of thin air. To do this properly, we should probably have some part of the
  * errors in LDB be allocated to bindings ? */
 #define LDB_ERR_PYTHON_EXCEPTION       142