summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4201b3d)
raw | patch | inline | side by side (parent: 4201b3d)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 28 May 2009 09:15:41 +0000 (11:15 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 28 May 2009 10:25:05 +0000 (12:25 +0200) |
When including empty files, a typo prevented that the "Include" child (of the
config parse tree) was removed correctly, leaving behind garbage which in turn
led to a segfault if the Include option was not the last element of the config
file.
Also, another Include option following the inclusion of an empty file used to
be ignored. This has been fixed as well.
config parse tree) was removed correctly, leaving behind garbage which in turn
led to a segfault if the Include option was not the last element of the config
file.
Also, another Include option following the inclusion of an empty file used to
be ignored. This has been fixed as well.
src/configfile.c | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index c929d0097aef6279db09c61411442cf3ddef99aa..0bb46e4004d679a504c51a699408774b70f81b07 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
temp = NULL;
/* If (src->children_num == 0) the array size is decreased. If offset
- * is _not_ the last element, (offset < (src->children_num - 1)), then
+ * is _not_ the last element, (offset < (dst->children_num - 1)), then
* we need to move the trailing elements before resizing the array. */
- if ((src->children_num == 0) && (offset < (src->children_num - 1)))
+ if ((src->children_num == 0) && (offset < (dst->children_num - 1)))
{
- int nmemb = src->children_num - (offset + 1);
- memmove (src->children + offset, src->children + offset + 1,
+ int nmemb = dst->children_num - (offset + 1);
+ memmove (dst->children + offset, dst->children + offset + 1,
sizeof (oconfig_item_t) * nmemb);
}
sizeof (oconfig_item_t) * nmemb);
}
- /* Last but not least: If there are new childrem, copy them to the
+ /* Last but not least: If there are new children, copy them to the
* memory reserved for them. */
if (src->children_num > 0)
{
/* Now replace the i'th child in `root' with `new'. */
cf_ci_replace_child (root, new, i);
+ /* ... and go back to the new i'th child. */
+ --i;
+
sfree (new->values);
sfree (new);
} /* for (i = 0; i < root->children_num; i++) */