Make sure OPENSSL_cleanse checks for NULL
authorMatt Caswell <matt@openssl.org>
Wed, 16 Sep 2015 09:47:15 +0000 (10:47 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 17 Sep 2015 21:33:31 +0000 (22:33 +0100)
commita50a8a76dd19bdcb3c2544fbf36e9238779cef3a
treea795b8794b97a51bef9c5cc91dd58f0d5ba128d8
parent7ac2c47583242343cf2ac001730a343118c21d56
Make sure OPENSSL_cleanse checks for NULL

In master we have the function OPENSSL_clear_free(x,y), which immediately
returns if x == NULL. In <=1.0.2 this function does not exist so we have to
do:
OPENSSL_cleanse(x, y);
OPENSSL_free(x);

However, previously, OPENSSL_cleanse did not check that if x == NULL, so
the real equivalent check would have to be:
if (x != NULL)
    OPENSSL_cleanse(x, y);
OPENSSL_free(x);

It would be easy to get this wrong during cherry-picking to other branches
and therefore, for safety, it is best to just ensure OPENSSL_cleanse also
checks for NULL.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 020d8fc83fe1a94232db1ee1166309e2458a8a18)
crypto/mem_clr.c