Skip to content

Commit 5abac28

Browse files
committed
Fix potential memory leak if connecting fails
1 parent d4069f4 commit 5abac28

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/njs/src/njsConnection.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ void Connection::ProcessBinds (_NAN_METHOD_ARGS, unsigned int index,
423423
void Connection::ProcessOptions (_NAN_METHOD_ARGS, unsigned int index,
424424
eBaton* executeBaton)
425425
{
426+
NanScope();
426427
Local<Object> options;
427428
if(args[index]->IsObject() && !args[index]->IsArray())
428429
{
@@ -446,7 +447,8 @@ void Connection::ProcessOptions (_NAN_METHOD_ARGS, unsigned int index,
446447
Local<Array> keys = fetchInfo->GetOwnPropertyNames ();
447448
if ( keys->Length () > 0 )
448449
{
449-
FetchInfo *fInfo = new FetchInfo[keys->Length()];
450+
FetchInfo *fInfo = executeBaton->fetchInfo =
451+
new FetchInfo[keys->Length()];
450452
executeBaton->fetchInfoCount = keys->Length ();
451453

452454
for (unsigned int index = 0 ; index < keys->Length() ; index ++ )
@@ -472,7 +474,6 @@ void Connection::ProcessOptions (_NAN_METHOD_ARGS, unsigned int index,
472474
goto exitProcessOptions;
473475
}
474476
}
475-
executeBaton->fetchInfo = fInfo;
476477
}
477478
else
478479
{

0 commit comments

Comments
 (0)