job: be more careful when removing job object from jobs hash table
authorLennart Poettering <lennart@poettering.net>
Mon, 10 Dec 2018 18:38:38 +0000 (19:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 12 Dec 2018 10:15:07 +0000 (11:15 +0100)
Let's validate that the ID is actually allocated to us before remove a
job.

This is relevant as various bits of code will call job_free() on
partially set up Job objects, and we really shouldn't remove another job
object accidentally from the hash table, when the set up didn't
complete.

src/core/job.c

index 7fa3673..8106a78 100644 (file)
@@ -151,7 +151,7 @@ void job_uninstall(Job *j) {
 
         unit_add_to_gc_queue(j->unit);
 
-        hashmap_remove(j->manager->jobs, UINT32_TO_PTR(j->id));
+        hashmap_remove_value(j->manager->jobs, UINT32_TO_PTR(j->id), j);
         j->installed = false;
 }