1
0
Fork 0

Fix compilation on Windows for S2 and VS 2017. (#5267)

* Fix compilation on Windows VS 2017 (s2).

* Improve compilation fix for windows.
This commit is contained in:
Max Neunhöffer 2018-05-04 21:31:03 +02:00 committed by GitHub
parent acab8b45f6
commit b1aac15764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include <algorithm>
#include <cmath>
#include <limits>
#include <memory>
#include <openssl/bn.h>
#include <openssl/crypto.h> // for OPENSSL_free
@ -134,7 +135,16 @@ static int BN_ext_count_low_zero_bits(const BIGNUM* bn) {
// converts the absolute value of `a into little-endian form and
// stores it at `to`. `tolen` indicates the length of the output buffer `to`
int size = BN_num_bytes(bn);
unsigned char bin[size];
unsigned char buf[80];
std::unique_ptr<unsigned char> bin_up;
unsigned char* bin;
if (size <= 80) {
bin = buf;
} else {
bin_up.reset(new unsigned char[size]);
bin = bin_up.get();
}
size = BN_bn2lebinpad(bn, bin, size);
for (int i = 0; i < size; ++i) {