bn2binpad: Use memset as the buffer will be used later
[openssl.git] / crypto / bn / bn_lib.c
index 28a3e91679d78ec4df9cb9035132846e39e80e90..d37b89c2a6e64cdb41897f0a7c577c3a5591ec44 100644 (file)
@@ -505,7 +505,8 @@ int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endiane
     /* Swipe through whole available data and don't give away padded zero. */
     atop = a->dmax * BN_BYTES;
     if (atop == 0) {
-        OPENSSL_cleanse(to, tolen);
+        if (tolen != 0)
+            memset(to, '\0', tolen);
         return tolen;
     }