Fixed NULL pointer dereference in PKCS7_dataDecode reported by David Ramos in PR#3339
fix coverity issue 966597 - error line is not always initialised
PR#3342 fix resource leak coverity issue 966577
coverity 966576 - close socket in error path
Unit/regression test for TLS heartbeats.

Regression test against CVE-2014-0160 (Heartbleed).

More info: http://mike-bland.com/tags/heartbleed.html

(based on commit 35cb55988b75573105eefd00d27d0138eebe40b1)