[icinga-checkins] icinga.org: icinga-core/mfriedrich/ido: idoutils: fix ido2db_get_cached_object_ids fetches only one object_id and leaves memory fragments (thx Klaus Wagner) refs #3409
git at icinga.org
git at icinga.org
Mon Oct 29 20:40:56 CET 2012
Module: icinga-core
Branch: mfriedrich/ido
Commit: 74dea3f38c9399dddf49931f66330f5cb5cdc250
URL: https://git.icinga.org/?p=icinga-core.git;a=commit;h=74dea3f38c9399dddf49931f66330f5cb5cdc250
Author: Michael Friedrich <michael.friedrich at gmail.com>
Date: Mon Oct 29 20:17:36 2012 +0100
idoutils: fix ido2db_get_cached_object_ids fetches only one object_id and leaves memory fragments (thx Klaus Wagner) refs #3409
---
module/idoutils/src/dbhandlers.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index c25ebe0..6ea287f 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -535,10 +535,8 @@ int ido2db_get_cached_object_ids(ido2db_idi *idi) {
if ((result = ido2db_db_query(idi, buf)) == IDO_OK) {
while (idi->dbinfo.dbi_result) {
if (dbi_result_next_row(idi->dbinfo.dbi_result)) {
- object_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result,
- "object_id");
- objecttype_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result,
- "objecttype_id");
+ object_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result, "object_id");
+ objecttype_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result, "objecttype_id");
/* get string and free it later on */
if (asprintf(&tmp1, "%s", dbi_result_get_string_copy(idi->dbinfo.dbi_result, "name1")) == -1)
@@ -551,10 +549,14 @@ int ido2db_get_cached_object_ids(ido2db_idi *idi) {
free(tmp1);
free(tmp2);
+ } else {
+ dbi_result_free(idi->dbinfo.dbi_result);
+ idi->dbinfo.dbi_result = NULL;
}
- dbi_result_free(idi->dbinfo.dbi_result);
- idi->dbinfo.dbi_result = NULL;
}
+ } else {
+ dbi_result_free(idi->dbinfo.dbi_result);
+ idi->dbinfo.dbi_result = NULL;
}
free(buf);
More information about the icinga-checkins
mailing list