From 29243e7f552f4a61f582f23ac36ff114be605a23 Mon Sep 17 00:00:00 2001 From: blackjok3r <blackjok3r@gmail.com> Date: Sat, 16 Mar 2019 19:33:42 +0800 Subject: [PATCH] try fix mor memleaks --- iguana/dpow/dpow_fsm.c | 12 +++++++++--- iguana/dpow/dpow_rpc.c | 2 ++ iguana/dpow/dpow_tx.c | 4 +++- iguana/iguana_rpc.c | 5 +++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 615733269..5b8531aa6 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -669,8 +669,11 @@ void dpow_statemachinestart(void *ptr) fprintf(stderr, "[%s] Cant find tx.%s rebroadcasting...\n", dp->dest, bits256_str(str,bp->desttxid)); send_dest = 1; } else fprintf(stderr, "[%s] get raw transaction error\n", dp->dest); - if ( send_dest == 1 ) - dpow_sendrawtransaction(myinfo, bp->destcoin, desttx); + if ( send_src == 1 ) + { + char *tmpstr = dpow_sendrawtransaction(myinfo, bp->destcoin, desttx); + free(tempstr); + } } // get the confirms for srctxid @@ -701,7 +704,10 @@ void dpow_statemachinestart(void *ptr) send_src = 1; } else fprintf(stderr, "[%s] get raw transaction error\n", dp->symbol); if ( send_src == 1 ) - dpow_sendrawtransaction(myinfo, bp->srccoin, srctx); + { + char *tmpstr = dpow_sendrawtransaction(myinfo, bp->srccoin, srctx); + free(tempstr); + } } } #endif diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 9cf597673..f8de02ec5 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -153,6 +153,8 @@ int32_t komodo_initjson2(char *fstr) { Notaries_elected[i][0] = clonestr(field); Notaries_elected[i][1] = clonestr(hexstr); + free(feild); + free(hexstr); //printf("%d of %d: %s %s\n",i,n,field,hexstr); } else diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 7f1a07025..4954fd177 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -531,7 +531,9 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu } if ( valid != 0 ) { - printf("bestk.%d %llx %s height.%d mod.%d VINI.%d myind.%d MINE.(%s) j.%d\n",bestk,(long long)bestmask,(src_or_dest != 0) ? bp->destcoin->symbol : bp->srccoin->symbol,bp->height,DPOW_MODIND(bp,0),j,myind,jprint(item,0),j); + char *txinfo = jprint(item,0); + printf("bestk.%d %llx %s height.%d mod.%d VINI.%d myind.%d MINE.(%s) j.%d\n",bestk,(long long)bestmask,(src_or_dest != 0) ? bp->destcoin->symbol : bp->srccoin->symbol,bp->height,DPOW_MODIND(bp,0),j,myind,txinfo,j); + free(txinfo); cp->siglens[bestk] = (int32_t)strlen(sigstr) >> 1; if ( src_or_dest != 0 ) bp->destsigsmasks[bestk] |= (1LL << myind); diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 719de3013..7e304a064 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -1302,9 +1302,10 @@ void iguana_rpcloop(void *args) printf("iguana sent.%d remains.%d of len.%d\n",numsent,remains,recvlen); } } - if ( retstr != space) - free(retstr); + //if ( retstr != space) + // free(retstr); } + free(retstr); closesocket(sock); } }