浏览代码

Notify_dependencies may free the completion group structure while we still have
to access the tag it referenced.

Cédric Augonnet 16 年之前
父节点
当前提交
53b76fc51b
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/core/dependencies/tags.c

+ 6 - 4
src/core/dependencies/tags.c

@@ -228,14 +228,16 @@ void notify_dependencies(struct job_s *j)
 		for (succ = 0; succ < nsuccs; succ++)
 		{
 			struct _cg_t *cg = tag->succ[succ];
+			unsigned used_by_apps = cg->used_by_apps;
+			struct tag_s *cgtag = cg->tag;
 
-			if (!cg->used_by_apps)
-				take_mutex(&cg->tag->lock);
+			if (!used_by_apps)
+				take_mutex(&cgtag->lock);
 
 			notify_cg(cg);
 
-			if (!cg->used_by_apps)
-				release_mutex(&cg->tag->lock);
+			if (!used_by_apps)
+				release_mutex(&cgtag->lock);
 		}
 
 		release_mutex(&tag->lock);