summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2024-02-22 11:19:30 +1300
committerAndrew Bartlett <abartlet@samba.org>2024-02-29 04:01:40 +0000
commitcccc994fa076f3f784bce7258a95d756d44cd190 (patch)
treec69b7f5fe0b42ae23c00cef50d304825db140875 /lib
parent8cf9d4cae1e73077c463648a7fcc9cbf329c03ec (diff)
downloadsamba-cccc994fa076f3f784bce7258a95d756d44cd190.tar.gz
samba-cccc994fa076f3f784bce7258a95d756d44cd190.tar.bz2
samba-cccc994fa076f3f784bce7258a95d756d44cd190.zip
pyldb: add a macro to free when raising exceptions
We often forget. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/pyldb.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ldb/pyldb.h b/lib/ldb/pyldb.h
index 2d354422cdb..45637b76691 100644
--- a/lib/ldb/pyldb.h
+++ b/lib/ldb/pyldb.h
@@ -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