[PATCH] s3/passdb/py_passdb.c: free frame before returning

Jeremy Allison jra at samba.org
Mon Feb 29 19:52:05 UTC 2016


On Mon, Feb 29, 2016 at 06:39:47PM +0100, Aurélien Aptel wrote:
> Hi,
> 
> This file contains several functions where the talloc frames are freed
> after returning from the function this leaking memory in some cases.
> 
> Please review/comment/push

Oh - good catch ! Obvious goodness.

Reviewed-by: Jeremy Allison <jra at samba.org>

Can I get a second Team reviewer ?

> -- 
> Aurélien Aptel / SUSE Labs Samba Team
> GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
> SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
> GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG
> Nürnberg)

> From 7d70ab0a73bf8c021e0dc90daf63336de5cfed32 Mon Sep 17 00:00:00 2001
> From: Aurelien Aptel <aaptel at suse.com>
> Date: Mon, 29 Feb 2016 18:23:39 +0100
> Subject: [PATCH 7/7] s3/passdb/py_passdb.c: free frame before returning
> 
> these talloc frames are freed *after* the return instruction and are
> never executed. this fixes potential memory leaks.
> 
> Signed-off-by: Aurelien Aptel <aaptel at suse.com>
> ---
>  source3/passdb/py_passdb.c | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
> index 0d4ca3b..c791ead 100644
> --- a/source3/passdb/py_passdb.c
> +++ b/source3/passdb/py_passdb.c
> @@ -1501,8 +1501,8 @@ static PyObject *py_pdb_delete_user(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyObject *py_pdb_add_sam_account(pytalloc_Object *self, PyObject *args)
> @@ -1532,8 +1532,8 @@ static PyObject *py_pdb_add_sam_account(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyObject *py_pdb_update_sam_account(pytalloc_Object *self, PyObject *args)
> @@ -1562,8 +1562,8 @@ static PyObject *py_pdb_update_sam_account(pytalloc_Object *self, PyObject *args
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyObject *py_pdb_delete_sam_account(pytalloc_Object *self, PyObject *args)
> @@ -1592,8 +1592,8 @@ static PyObject *py_pdb_delete_sam_account(pytalloc_Object *self, PyObject *args
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyObject *py_pdb_rename_sam_account(pytalloc_Object *self, PyObject *args)
> @@ -1624,8 +1624,8 @@ static PyObject *py_pdb_rename_sam_account(pytalloc_Object *self, PyObject *args
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -1802,8 +1802,8 @@ static PyObject *py_pdb_delete_dom_group(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -1833,8 +1833,8 @@ static PyObject *py_pdb_add_group_mapping_entry(pytalloc_Object *self, PyObject
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -1864,8 +1864,8 @@ static PyObject *py_pdb_update_group_mapping_entry(pytalloc_Object *self, PyObje
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -1895,8 +1895,8 @@ static PyObject *py_pdb_delete_group_mapping_entry(pytalloc_Object *self, PyObje
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2092,8 +2092,8 @@ static PyObject *py_pdb_add_groupmem(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2120,8 +2120,8 @@ static PyObject *py_pdb_del_groupmem(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2181,8 +2181,8 @@ static PyObject *py_pdb_delete_alias(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2281,8 +2281,8 @@ static PyObject *py_pdb_set_aliasinfo(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2314,8 +2314,8 @@ static PyObject *py_pdb_add_aliasmem(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2347,8 +2347,8 @@ static PyObject *py_pdb_del_aliasmem(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2470,8 +2470,8 @@ static PyObject *py_pdb_set_account_policy(pytalloc_Object *self, PyObject *args
>  		}
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyObject *py_pdb_search_users(pytalloc_Object *self, PyObject *args)
> @@ -2872,8 +2872,8 @@ static PyObject *py_pdb_set_trusteddom_pw(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -2896,8 +2896,8 @@ static PyObject *py_pdb_del_trusteddom_pw(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -3124,8 +3124,8 @@ static PyObject *py_pdb_set_trusted_domain(pytalloc_Object *self, PyObject *args
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -3152,8 +3152,8 @@ static PyObject *py_pdb_del_trusted_domain(pytalloc_Object *self, PyObject *args
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -3334,8 +3334,8 @@ static PyObject *py_pdb_set_secret(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> @@ -3363,8 +3363,8 @@ static PyObject *py_pdb_delete_secret(pytalloc_Object *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  static PyMethodDef py_pdb_methods[] = {
> @@ -3624,8 +3624,8 @@ static PyObject *py_set_smb_config(PyObject *self, PyObject *args)
>  		return NULL;
>  	}
>  
> -	Py_RETURN_NONE;
>  	talloc_free(frame);
> +	Py_RETURN_NONE;
>  }
>  
>  
> -- 
> 2.1.4
> 






More information about the samba-technical mailing list