Commit 89ce1a4480c687e4dc9bbda41b3824dcecf44928

Con Kolivas 2012-02-22T20:22:28

Merge pull request #133 from luke-jr/bugfix_bitforce_memleak Bugfix: Fix BitFORCE driver memory leak in debug logging

diff --git a/bitforce.c b/bitforce.c
index aaeef00..c283a61 100644
--- a/bitforce.c
+++ b/bitforce.c
@@ -204,6 +204,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 	unsigned char ob[61] = ">>>>>>>>12345678901234567890123456789012123456789012>>>>>>>>";
 	int i;
 	char *pnoncebuf;
+	char *pblkdata;
 	uint32_t nonce;
 
 	BFwrite(fdDev, "ZDX", 3);
@@ -220,7 +221,11 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 	memcpy(ob + 8, work->midstate, 32);
 	memcpy(ob + 8 + 32, work->data + 64, 12);
 	BFwrite(fdDev, ob, 60);
-	applog(LOG_DEBUG, "BitForce block data: %s", bin2hex(ob + 8, 44));
+	if (opt_debug) {
+		pblkdata = bin2hex(ob + 8, 44);
+		applog(LOG_DEBUG, "BitForce block data: %s", pblkdata);
+		free(pblkdata);
+	}
 
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	if (unlikely(!pdevbuf[0])) {