Sfoglia il codice sorgente

update-alternatives: avoid segfault when the only slave is disappearing

When an alternative with a single slave is removed, and when the
remaining alternatives have no slaves, u-a was segfaulting while trying
to remove the slave alternative from the structure.

Reported-by: Jonathan Nieder <jrnieder@gmail.com>
Reported-by: Cyril Brulebois <kibi@debian.org>
Raphaël Hertzog 16 anni fa
parent
commit
37fe6b4a5c
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      utils/update-alternatives.c

+ 2 - 0
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 */
 		}
 	}