fixed format string argument error, resulting in crash

fixed memleak if pool not found
This commit is contained in:
Martin Willi
2009-03-03 14:56:17 +00:00
parent 7b2a032d28
commit d9ad73d867
2 changed files with 15 additions and 3 deletions
@@ -17,6 +17,7 @@
#include "attribute_manager.h" #include "attribute_manager.h"
#include <daemon.h>
#include <utils/linked_list.h> #include <utils/linked_list.h>
#include <utils/mutex.h> #include <utils/mutex.h>
@@ -67,6 +68,10 @@ static host_t* acquire_address(private_attribute_manager_t *this,
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
if (!host)
{
DBG1(DBG_CFG, "acquiring address from pool '%s' failed", pool);
}
return host; return host;
} }
@@ -78,6 +83,7 @@ static void release_address(private_attribute_manager_t *this,
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
attribute_provider_t *current; attribute_provider_t *current;
bool found = FALSE;
this->lock->read_lock(this->lock); this->lock->read_lock(this->lock);
enumerator = this->providers->create_enumerator(this->providers); enumerator = this->providers->create_enumerator(this->providers);
@@ -85,11 +91,17 @@ static void release_address(private_attribute_manager_t *this,
{ {
if (current->release_address(current, pool, address, id)) if (current->release_address(current, pool, address, id))
{ {
found = TRUE;
break; break;
} }
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
if (!found)
{
DBG1(DBG_CFG, "releasing address to pool '%s' failed", pool);
}
} }
/** /**
+1 -1
View File
@@ -89,7 +89,7 @@ static u_int get_pool(private_sql_attribute_t *this, char *name, u_int *timeout)
e->destroy(e); e->destroy(e);
return pool; return pool;
} }
DBG1(DBG_CFG, "ip pool '%s' not found"); DESTROY_IF(e);
return 0; return 0;
} }