Browse Source

Revert "No need for extra variable in hash_push.": The extra variable is needed to avoid a rare dereference-after-free error.

This reverts commit 51d485e236586661771f0469ccf1598e3f80ae70.
Luke Dashjr 13 years ago
parent
commit
aa5ac58d0b
1 changed files with 7 additions and 4 deletions
  1. 7 4
      cgminer.c

+ 7 - 4
cgminer.c

@@ -2882,7 +2882,12 @@ static bool work_rollable(struct work *work)
 
 
 static bool hash_push(struct work *work)
 static bool hash_push(struct work *work)
 {
 {
-	bool rc = true;
+	bool rc = true, dec = false;
+
+	if (work->queued) {
+		work->queued = false;
+		dec = true;
+	}
 
 
 	mutex_lock(stgd_lock);
 	mutex_lock(stgd_lock);
 	if (work_rollable(work))
 	if (work_rollable(work))
@@ -2895,10 +2900,8 @@ static bool hash_push(struct work *work)
 	pthread_cond_signal(&getq->cond);
 	pthread_cond_signal(&getq->cond);
 	mutex_unlock(stgd_lock);
 	mutex_unlock(stgd_lock);
 
 
-	if (work->queued) {
-		work->queued = false;
+	if (dec)
 		dec_queued();
 		dec_queued();
-	}
 
 
 	return rc;
 	return rc;
 }
 }