summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dff3369)
raw | patch | inline | side by side (parent: dff3369)
author | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 15:28:39 +0000 (17:28 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 15:28:39 +0000 (17:28 +0200) |
"r_area->next" was evaluated after "r_area" was freed.
src/utils_db_query.c | patch | blob | history |
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index aadf9c5ec1d7f6a4879a5701ebe19f2a25d23633..ab4299b3a84675e8be8fdc2adfdf7ca879d807fe 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
udb_result_preparation_area_t **next_r_area;
udb_result_t *r;
- q_area = (udb_query_preparation_area_t *)malloc (sizeof (*q_area));
+ q_area = malloc (sizeof (*q_area));
if (q_area == NULL)
return NULL;
-
memset (q_area, 0, sizeof (*q_area));
next_r_area = &q_area->result_prep_areas;
{
udb_result_preparation_area_t *r_area;
- r_area = (udb_result_preparation_area_t *)malloc (sizeof (*r_area));
+ r_area = malloc (sizeof (*r_area));
if (r_area == NULL)
{
- for (r_area = q_area->result_prep_areas;
- r_area != NULL; r_area = r_area->next)
+ udb_result_preparation_area_t *a = q_area->result_prep_areas;
+
+ while (a != NULL)
{
- free (r_area);
+ udb_result_preparation_area_t *next = a->next;
+ sfree (a);
+ a = next;
}
+
free (q_area);
return NULL;
}