Browse Source

Bugfix: Save pool pointer to avoid dereferencing work after it might potentially be freed

Luke Dashjr 13 years ago
parent
commit
509b6f209a
1 changed files with 3 additions and 2 deletions
  1. 3 2
      cgminer.c

+ 3 - 2
cgminer.c

@@ -2922,6 +2922,7 @@ static bool work_rollable(struct work *work)
 static bool hash_push(struct work *work)
 static bool hash_push(struct work *work)
 {
 {
 	bool rc = true, dec = false;
 	bool rc = true, dec = false;
+	struct pool *pool = work->pool;
 
 
 	if (work->queued) {
 	if (work->queued) {
 		work->queued = false;
 		work->queued = false;
@@ -2929,7 +2930,7 @@ static bool hash_push(struct work *work)
 	}
 	}
 
 
 	mutex_lock(stgd_lock);
 	mutex_lock(stgd_lock);
-	work->pool->staged++;
+	pool->staged++;
 	if (work_rollable(work))
 	if (work_rollable(work))
 		staged_rollable++;
 		staged_rollable++;
 	if (likely(!getq->frozen)) {
 	if (likely(!getq->frozen)) {
@@ -2941,7 +2942,7 @@ static bool hash_push(struct work *work)
 	mutex_unlock(stgd_lock);
 	mutex_unlock(stgd_lock);
 
 
 	if (dec)
 	if (dec)
-		dec_queued(work->pool);
+		dec_queued(pool);
 
 
 	return rc;
 	return rc;
 }
 }