Skip to content

Commit c5ca3bf

Browse files
authored
Merge pull request #30 from jay602/master
插件发送消息可能泄露 #998
2 parents 49ef85b + e72a358 commit c5ca3bf

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

kbengine.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,8 @@ KBEngine.Bundle = function()
971971
this.writeMsgLength(this.messageLength);
972972
if(this.stream)
973973
this.memorystreams.push(this.stream);
974+
975+
this.stream = KBEngine.MemoryStream.createObject();
974976
}
975977

976978
if(issend)
@@ -990,12 +992,8 @@ KBEngine.Bundle = function()
990992
{
991993
var tmpStream = this.memorystreams[i];
992994
network.send(tmpStream.getbuffer());
993-
tmpStream.reclaimObject();
994995
}
995996

996-
this.memorystreams = new Array();
997-
this.stream = KBEngine.MemoryStream.createObject();
998-
999997
this.reclaimObject();
1000998
}
1001999

@@ -1086,7 +1084,18 @@ KBEngine.Bundle = function()
10861084

10871085
this.clear = function()
10881086
{
1089-
this.stream = KBEngine.MemoryStream.createObject();
1087+
for(var i=0; i<this.memorystreams.length; i++)
1088+
{
1089+
if(this.stream != this.memorystreams[i])
1090+
this.memorystreams[i].reclaimObject();
1091+
}
1092+
1093+
1094+
if(this.stream)
1095+
this.stream.clear();
1096+
else
1097+
this.stream = KBEngine.MemoryStream.createObject();
1098+
10901099
this.memorystreams = new Array();
10911100
this.numMessage = 0;
10921101
this.messageLengthBuffer = null;

0 commit comments

Comments
 (0)