common: Smart up register_mem_cleanup_func.

* common/init.c (register_mem_cleanup_func): Avoid double registration.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-07-01 14:42:18 +02:00
parent 49fdd0887c
commit 6446a6b3df
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 4 additions and 0 deletions

View File

@ -106,6 +106,10 @@ register_mem_cleanup_func (void (*func)(void))
{
mem_cleanup_item_t item;
for (item = mem_cleanup_list; item; item = item->next)
if (item->func == func)
return; /* Function has already been registered. */
item = malloc (sizeof *item);
if (item)
{