Skip to content

Commit 673b3fb

Browse files
committed
fix memory leak when reconnect
1 parent df64e05 commit 673b3fb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

MicroGear.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void MicroGear::syncTime(Client *client, unsigned long *bts) {
8484
MicroGear::MicroGear(Client& netclient ) {
8585
sockclient = &netclient;
8686
constate = CLIENT_NOTCONNECT;
87+
authclient = NULL;
8788

8889
this->token = NULL;
8990
this->tokensecret = NULL;
@@ -309,10 +310,12 @@ boolean MicroGear::connect(char* appid) {
309310
this->appid = appid;
310311
topicprefixlen = strlen(appid)+1;
311312

313+
if (authclient) delete(authclient);
312314
authclient = new AuthClient(*sockclient);
313315
authclient->init(appid,scope,bootts);
314316
getToken(token,tokensecret,endpoint);
315317
delete(authclient);
318+
authclient = NULL;
316319

317320
/* generate one-time user/password */
318321
sprintf(username,"%s%%%s%%%lu",token,gearkey,bootts+millis()/1000);

0 commit comments

Comments
 (0)