Browse Source

Bugfix: Fix BitFORCE driver memory leak in debug logging

Luke Dashjr 14 years ago
parent
commit
829dcf9d2b
1 changed files with 6 additions and 1 deletions
  1. 6 1
      bitforce.c

+ 6 - 1
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])) {