Use delete[] after new[]

gmake: Wejście do katalogu '/usr/home/saper/sw/misskey/build'
  CXX(target) Release/obj.target/crypto_key/src/crypto_key.o
../src/crypto_key.cc:25:3: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?
      [-Wmismatched-new-delete]
                delete sourceBuf;
                ^
                      []
../src/crypto_key.cc:18:25: note: allocated with 'new[]' here
        const auto sourceBuf = new char[sourceLength];
                               ^
../src/crypto_key.cc:32:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?
      [-Wmismatched-new-delete]
        delete sourceBuf;
        ^
              []
../src/crypto_key.cc:18:25: note: allocated with 'new[]' here
        const auto sourceBuf = new char[sourceLength];
                               ^
2 warnings generated.
This commit is contained in:
Marcin Cieślak 2018-05-16 00:20:37 +02:00
parent 87862ba18b
commit 7d881427d4

View File

@ -22,14 +22,14 @@ NAN_METHOD(extractPublic)
const auto source = BIO_new_mem_buf(sourceBuf, sourceLength); const auto source = BIO_new_mem_buf(sourceBuf, sourceLength);
if (source == nullptr) { if (source == nullptr) {
Nan::ThrowError("Memory allocation failed"); Nan::ThrowError("Memory allocation failed");
delete sourceBuf; delete[] sourceBuf;
return; return;
} }
const auto rsa = PEM_read_bio_RSAPrivateKey(source, nullptr, nullptr, nullptr); const auto rsa = PEM_read_bio_RSAPrivateKey(source, nullptr, nullptr, nullptr);
BIO_free(source); BIO_free(source);
delete sourceBuf; delete[] sourceBuf;
if (rsa == nullptr) { if (rsa == nullptr) {
Nan::ThrowError("Decode failed"); Nan::ThrowError("Decode failed");