Skip to content

Commit 6fb8f5f

Browse files
Check that -blocknotify command is non-empty before executing
To make BlockNotifyCallback(...) (-blocknotify) consistent with: * AlertNotify(...) (-alertnotify) * AddToWallet(...) (-walletnotify)
1 parent 140de14 commit 6fb8f5f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/init.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,10 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex
547547
return;
548548

549549
std::string strCmd = gArgs.GetArg("-blocknotify", "");
550-
551-
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
552-
boost::thread t(runCommand, strCmd); // thread runs free
550+
if (!strCmd.empty()) {
551+
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
552+
boost::thread t(runCommand, strCmd); // thread runs free
553+
}
553554
}
554555

555556
static bool fHaveGenesis = false;

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
988988
// notify an external script when a wallet transaction comes in or is updated
989989
std::string strCmd = gArgs.GetArg("-walletnotify", "");
990990

991-
if ( !strCmd.empty())
991+
if (!strCmd.empty())
992992
{
993993
boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex());
994994
boost::thread t(runCommand, strCmd); // thread runs free

0 commit comments

Comments
 (0)