[PATCH] pyldb: decrement ref counters on py_results and quiet, warnings

Jelmer Vernooij jelmer at samba.org
Fri May 17 17:08:12 MDT 2013


On Fri, May 17, 2013 at 10:35:13AM -0700, Matthieu Patou wrote:
> Hello,
> 
> Can someone review this patch ?
> 
> The problem is that the variable is not used so it raise a set but
> not used warning, we can't just ignore the result otherwise we would
> leak memory.

You probably want Py_XDECREF(py_result), which is a noop if py_result is NULL.

Cheers,

Jelmer

> 
> Thanks.
> 
> Matthieu.
> 
> 
> -- 
> Matthieu Patou
> Samba Team
> http://samba.org
> 
> 

> From 6c6c325017fb2cfc1b758cc70e0d9424e5294cf1 Mon Sep 17 00:00:00 2001
> From: Matthieu Patou <mat at matws.net>
> Date: Wed, 26 Dec 2012 21:36:50 -0800
> Subject: [PATCH 1/2] pyldb: decrement ref counters on py_results and quiet
>  warnings
> 
> Signed-off-by: Matthieu Patou <mat at matws.net>
> ---
>  lib/ldb/pyldb.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
> index 8c9d6b9..6c50ccf 100644
> --- a/lib/ldb/pyldb.c
> +++ b/lib/ldb/pyldb.c
> @@ -3088,6 +3088,10 @@ static int py_module_request(struct ldb_module *mod, struct ldb_request *req)
>  	py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "request"),
>  					discard_const_p(char, ""));
>  
> +	if (py_result != NULL) {
> +		Py_DECREF(py_result);
> +	}
> +
>  	return LDB_ERR_OPERATIONS_ERROR;
>  }
>  
> @@ -3099,6 +3103,10 @@ static int py_module_extended(struct ldb_module *mod, struct ldb_request *req)
>  	py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "extended"),
>  					discard_const_p(char, ""));
>  
> +	if (py_result != NULL) {
> +		Py_DECREF(py_result);
> +	}
> +
>  	return LDB_ERR_OPERATIONS_ERROR;
>  }
>  
> -- 
> 1.7.9.5
> 


-- 


More information about the samba-technical mailing list