From c1243f1beafbdd2acb557ec90132c84e07e24532 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:05:18 -1100 Subject: [PATCH] Add error check to getscriptaddress --- src/cc/CCutils.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 2430a9b37..3501b8652 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -208,10 +208,14 @@ void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, u bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) + destaddr[0] = 0; + if ( scriptPubKey.begin() != 0 ) { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } } //fprintf(stderr,"ExtractDestination failed\n"); return(false);