[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Two quick bug reports



Hi,

On Wed, 21 Jul 2010, Jonathan Nieder wrote:
> Maybe the problem has to do with slave links.

With disappearing slave link in fact.

On Thu, 22 Jul 2010, Cyril Brulebois wrote:
> Cyril Brulebois <kibi@debian.org> (22/07/2010):
> > | 1217		for (sl = a->slaves; sl; sl_prev = sl, sl = sl->next) {
> 
> Unless I'm missing something, the “increment” part is processed before
> the condition is checked, meaning one can happily dereference sl
> without checking for its being non-0.

Except that if "sl" is NULL from the start, the loop is not executed. We
run into the problem because there's one slave but it's removed and thus
the second iteration fails, we should stop before going further in that
case.

Can you verify if the attached patch is enough?

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer ◈ [Flattr=20693]

Follow my Debian News ▶ http://RaphaelHertzog.com (English)
                      ▶ http://RaphaelHertzog.fr (Français)
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 972d173..0f6487a 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1236,6 +1236,8 @@ alternative_save(struct alternative *a, const char *file)
 			sl_rm = sl;
 			sl = sl_prev ? sl_prev : a->slaves;
 			slave_link_free(sl_rm);
+			if (!sl)
+				break; /* no other slave left */
 		}
 	}
 

Reply to: