summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-07 20:42:58 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-07 20:42:58 -0400
commite66047ff62c971eefa32b42373420d61e3f2a9c1 (patch)
treebbc8cf991b4e45f5c7614ed446674a2472643b50 /src/core/unit.c
parent17a6dfa3be0ac9d9b84b57c8af66515b573fc1a4 (diff)
core: do not add dependencies to self
Adds a pair of files which cause a segfault (also with systemd-analyze verify). https://bugzilla.redhat.com/show_bug.cgi?id=1124843
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index b68796a941..092673256d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -597,14 +597,22 @@ static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
UnitDependency k;
for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++) {
- r = set_remove_and_put(back->dependencies[k], other, u);
- if (r == -EEXIST)
+ /* Do not add dependencies between u and itself */
+ if (back == u) {
set_remove(back->dependencies[k], other);
- else
- assert(r >= 0 || r == -ENOENT);
+ } else {
+ r = set_remove_and_put(back->dependencies[k], other, u);
+ if (r == -EEXIST)
+ set_remove(back->dependencies[k], other);
+ else
+ assert(r >= 0 || r == -ENOENT);
+ }
}
}
+ /* Also do not move dependencies on u to itself */
+ set_remove(other->dependencies[d], u);
+
complete_move(&u->dependencies[d], &other->dependencies[d]);
set_free(other->dependencies[d]);