From be58861a590b307146f7ed860660141cdf0cd3d7 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Tue, 28 Jul 2020 07:30:13 +0000 Subject: [PATCH] function pointer may be null --- src/sync/src/syncMain.c | 3 ++- src/sync/src/syncRetrieve.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index e70e27b0ef..04e402769b 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -537,7 +537,8 @@ static void syncResetFlowCtrl(SSyncNode *pNode) { pNode->peerInfo[i]->numOfRetrieves = 0; } - (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); + if (pNode->notifyFlowCtrl) + (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); } static void syncChooseMaster(SSyncNode *pNode) { diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index be3a3c2ac7..7bd97f5abe 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -477,11 +477,12 @@ void *syncRetrieveData(void *param) if (pPeer->fileChanged) { // if file is changed 3 times continuously, start flow control pPeer->numOfRetrieves++; - if (pPeer->numOfRetrieves >= 3) + if (pPeer->numOfRetrieves >= 3 && pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->ahandle, pPeer->numOfRetrieves - 2); } else { pPeer->numOfRetrieves = 0; - (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); + if (pNode->notifyFlowCtrl) + (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); } pPeer->fileChanged = 0; -- GitLab