Fix double-free or corruption in tor22
The first commit is the test, courtesy of #44 (comment 25635). The second commit is the patch implied by #44 (comment 25632) and #44 (comment 25634).
The first commit is the test, courtesy of #44 (comment 25635). The second commit is the patch implied by #44 (comment 25632) and #44 (comment 25634).