If allocation in CRYPTO_clear_realloc() fails don't free up the original
buffer: this is consistent with the behaviour of realloc(3) and is expected
in other places in OpenSSL.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
}
ret = CRYPTO_malloc(num, file, line);
- if (ret)
+ if (ret != NULL) {
memcpy(ret, str, old_len);
- CRYPTO_clear_free(str, old_len, file, line);
+ CRYPTO_clear_free(str, old_len, file, line);
+ }
return ret;
}