mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
fix: resolve some memory leaks (#4939)
- In wallet/rpcdump memory the leak would happen, if wallet is not correct JSON - In BLS the leak would happen, if object hasn't been pushed in queue by some reason. Need to remove temporary object also
This commit is contained in:
parent
0835e4c307
commit
7b9f0acbdd
@ -269,7 +269,13 @@ struct Aggregator : public std::enable_shared_from_this<Aggregator<T>> {
|
||||
|
||||
void PushAggQueue(const T& v)
|
||||
{
|
||||
aggQueue.push(new T(v));
|
||||
auto copyT = new T(v);
|
||||
try {
|
||||
aggQueue.push(copyT);
|
||||
} catch (...) {
|
||||
delete copyT;
|
||||
throw;
|
||||
}
|
||||
|
||||
if (++aggQueueSize >= batchSize) {
|
||||
// we've collected enough intermediate results to form a new batch.
|
||||
|
@ -730,12 +730,13 @@ UniValue importelectrumwallet(const JSONRPCRequest& request)
|
||||
}
|
||||
} else {
|
||||
// json
|
||||
char* buffer = new char [nFilesize];
|
||||
file.read(buffer, nFilesize);
|
||||
UniValue data(UniValue::VOBJ);
|
||||
if(!data.read(buffer))
|
||||
{
|
||||
auto buffer = std::make_unique<char[]>(nFilesize);
|
||||
file.read(buffer.get(), nFilesize);
|
||||
if(!data.read(buffer.get()))
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Cannot parse Electrum wallet export file");
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
std::vector<std::string> vKeys = data.getKeys();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user