Browse Source

When not compiling with optimizations, initialize unused nonce2 space to avoid warnings from memory checking tools

Luke Dashjr 12 years ago
parent
commit
e9fc3874ad
1 changed files with 4 additions and 0 deletions
  1. 4 0
      miner.c

+ 4 - 0
miner.c

@@ -7177,6 +7177,10 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 
 
 	/* Generate coinbase */
 	/* Generate coinbase */
 	bytes_resize(&work->nonce2, pool->n2size);
 	bytes_resize(&work->nonce2, pool->n2size);
+#ifndef __OPTIMIZE__
+	if (pool->nonce2sz < pool->n2size)
+		memset(&bytes_buf(&work->nonce2)[pool->nonce2sz], 0, pool->n2size - pool->nonce2sz);
+#endif
 	memcpy(bytes_buf(&work->nonce2),
 	memcpy(bytes_buf(&work->nonce2),
 #ifdef WORDS_BIGENDIAN
 #ifdef WORDS_BIGENDIAN
 	// NOTE: On big endian, the most significant bits are stored at the end, so skip the LSBs
 	// NOTE: On big endian, the most significant bits are stored at the end, so skip the LSBs