Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! crypto: reduce memory usage of SignFinal
  • Loading branch information
tniessen committed Oct 17, 2018
commit 27f59473d55e03f8546182d4569f1ddfb160df38
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,7 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
return sign->CheckThrow(std::get<Error>(ret));

MallocedBuffer<unsigned char> sig =
std::get<MallocedBuffer<unsigned char>>(std::move(ret));
std::move(std::get<MallocedBuffer<unsigned char>>(ret));

Local<Object> rc =
Buffer::New(env, reinterpret_cast<char*>(sig.release()), sig.size)
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ struct MallocedBuffer {

inline bool is_empty() const { return data == nullptr; }

MallocedBuffer() : data(nullptr) {}
MallocedBuffer() : data(nullptr), size(0) {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I had a patch floating around I wanted to submit with this.

explicit MallocedBuffer(size_t size) : data(Malloc<T>(size)), size(size) {}
MallocedBuffer(T* data, size_t size) : data(data), size(size) {}
MallocedBuffer(MallocedBuffer&& other) : data(other.data), size(other.size) {
Expand Down