Skip to content

Commit 08bf937

Browse files
committed
Fix memory leak
Output buffer was allocated, but never freed
1 parent 1661676 commit 08bf937

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

multihashing.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Handle<Value> quark(const Arguments& args) {
3939
return except("Argument should be a buffer object.");
4040

4141
char * input = Buffer::Data(target);
42-
char * output = new char[32];
42+
char output[32];
4343

4444
uint32_t input_len = Buffer::Length(target);
4545

@@ -61,7 +61,7 @@ Handle<Value> x11(const Arguments& args) {
6161
return except("Argument should be a buffer object.");
6262

6363
char * input = Buffer::Data(target);
64-
char * output = new char[32];
64+
char output[32];
6565

6666
uint32_t input_len = Buffer::Length(target);
6767

@@ -83,7 +83,7 @@ Handle<Value> scrypt(const Arguments& args) {
8383
return except("Argument should be a buffer object.");
8484

8585
char * input = Buffer::Data(target);
86-
char * output = new char[32];
86+
char output[32];
8787

8888
uint32_t input_len = Buffer::Length(target);
8989

@@ -110,7 +110,7 @@ Handle<Value> scryptn(const Arguments& args) {
110110
unsigned int nFactor = num->Value();
111111

112112
char * input = Buffer::Data(target);
113-
char * output = new char[32];
113+
char output[32];
114114

115115
uint32_t input_len = Buffer::Length(target);
116116

@@ -148,7 +148,7 @@ Handle<Value> scryptjane(const Arguments& args) {
148148
int nMax = num4->Value();
149149

150150
char * input = Buffer::Data(target);
151-
char * output = new char[32];
151+
char output[32];
152152

153153
uint32_t input_len = Buffer::Length(target);
154154

@@ -170,7 +170,7 @@ Handle<Value> keccak(const Arguments& args) {
170170
return except("Argument should be a buffer object.");
171171

172172
char * input = Buffer::Data(target);
173-
char * output = new char[32];
173+
char output[32];
174174

175175
unsigned int dSize = Buffer::Length(target);
176176

@@ -193,7 +193,7 @@ Handle<Value> bcrypt(const Arguments& args) {
193193
return except("Argument should be a buffer object.");
194194

195195
char * input = Buffer::Data(target);
196-
char * output = new char[32];
196+
char output[32];
197197

198198
bcrypt_hash(input, output);
199199

@@ -213,7 +213,7 @@ Handle<Value> skein(const Arguments& args) {
213213
return except("Argument should be a buffer object.");
214214

215215
char * input = Buffer::Data(target);
216-
char * output = new char[32];
216+
char output[32];
217217

218218
uint32_t input_len = Buffer::Length(target);
219219

@@ -236,7 +236,7 @@ Handle<Value> groestl(const Arguments& args) {
236236
return except("Argument should be a buffer object.");
237237

238238
char * input = Buffer::Data(target);
239-
char * output = new char[32];
239+
char output[32];
240240

241241
uint32_t input_len = Buffer::Length(target);
242242

@@ -259,7 +259,7 @@ Handle<Value> groestl_myriad(const Arguments& args) {
259259
return except("Argument should be a buffer object.");
260260

261261
char * input = Buffer::Data(target);
262-
char * output = new char[32];
262+
char output[32];
263263

264264
uint32_t input_len = Buffer::Length(target);
265265

@@ -282,7 +282,7 @@ Handle<Value> blake(const Arguments& args) {
282282
return except("Argument should be a buffer object.");
283283

284284
char * input = Buffer::Data(target);
285-
char * output = new char[32];
285+
char output[32];
286286

287287
uint32_t input_len = Buffer::Length(target);
288288

@@ -305,7 +305,7 @@ Handle<Value> fugue(const Arguments& args) {
305305
return except("Argument should be a buffer object.");
306306

307307
char * input = Buffer::Data(target);
308-
char * output = new char[32];
308+
char output[32];
309309

310310
uint32_t input_len = Buffer::Length(target);
311311

@@ -328,7 +328,7 @@ Handle<Value> qubit(const Arguments& args) {
328328
return except("Argument should be a buffer object.");
329329

330330
char * input = Buffer::Data(target);
331-
char * output = new char[32];
331+
char output[32];
332332

333333
uint32_t input_len = Buffer::Length(target);
334334

@@ -351,7 +351,7 @@ Handle<Value> hefty1(const Arguments& args) {
351351
return except("Argument should be a buffer object.");
352352

353353
char * input = Buffer::Data(target);
354-
char * output = new char[32];
354+
char output[32];
355355

356356
uint32_t input_len = Buffer::Length(target);
357357

@@ -374,7 +374,7 @@ Handle<Value> shavite3(const Arguments& args) {
374374
return except("Argument should be a buffer object.");
375375

376376
char * input = Buffer::Data(target);
377-
char * output = new char[32];
377+
char output[32];
378378

379379
uint32_t input_len = Buffer::Length(target);
380380

0 commit comments

Comments
 (0)