Merge pull request #4761 from mpg/fix-memleak-in-ssl-test-2.x

[backport 2.x] Fix memory leak on failure path in test code