summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2006-02-17 13:29:52 +0000
committerPaul Smith <psmith@gnu.org>2006-02-17 13:29:52 +0000
commitbde826b18aeb6fd3c9de7a7733d1e163efde90e1 (patch)
tree8de85f137b768170247e18a2a2c95652a637530d /variable.c
parent0806a403d65ef6a7f16e2c17aa8286100ebad5d7 (diff)
downloadmake-git-bde826b18aeb6fd3c9de7a7733d1e163efde90e1.tar.gz
Make sure we don't introduce a circularity into the variable set linked
list. Fixes Savannah bug #15757.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/variable.c b/variable.c
index 0ea71cdb..39f0adaa 100644
--- a/variable.c
+++ b/variable.c
@@ -665,21 +665,27 @@ void
merge_variable_set_lists (struct variable_set_list **setlist0,
struct variable_set_list *setlist1)
{
- register struct variable_set_list *list0 = *setlist0;
+ struct variable_set_list *to = *setlist0;
struct variable_set_list *last0 = 0;
- while (setlist1 != 0 && list0 != 0)
+ /* If there's nothing to merge, stop now. */
+ if (!setlist1)
+ return;
+
+ /* This loop relies on the fact that all setlists terminate with the global
+ setlist (before NULL). If that's not true, arguably we SHOULD die. */
+ while (setlist1 != &global_setlist && to != &global_setlist)
{
- struct variable_set_list *next = setlist1;
+ struct variable_set_list *from = setlist1;
setlist1 = setlist1->next;
- merge_variable_sets (list0->set, next->set);
+ merge_variable_sets (to->set, from->set);
- last0 = list0;
- list0 = list0->next;
+ last0 = to;
+ to = to->next;
}
- if (setlist1 != 0)
+ if (setlist1 != &global_setlist)
{
if (last0 == 0)
*setlist0 = setlist1;