test/hash: fix potential memory leak