瀏覽代碼

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 年之前
父節點
當前提交
37fe6b4a5c
共有 1 個文件被更改,包括 2 次插入0 次删除
  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 */
 		}
 	}