if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )

This commit is contained in:
jl777
2019-02-20 23:08:13 -11:00
parent 2496f79e41
commit d9a52ff53c
3 changed files with 12 additions and 12 deletions

View File

@@ -86,7 +86,7 @@ int32_t musig_prevoutmsg(uint8_t *msg,uint256 sendtxid,CScript scriptPubKey)
UniValue musig_calcmsg(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
UniValue result(UniValue::VOBJ); uint256 sendtxid; int32_t i; uint8_t msg[32]; char *scriptstr,str[65]; int32_t n;
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n == 2 )
{
@@ -183,7 +183,7 @@ UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
txfee = MUSIG_TXFEE;
mypk = pubkey2pk(Mypubkey());
musigpk = GetUnspendable(cp,0);
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n == 2 && (hexstr= jstr(jitem(params,0),0)) != 0 && is_hexstr(hexstr,0) == 66 )
{
@@ -206,7 +206,7 @@ UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey mypk,pk; secp256k1_pubkey combined_pk; char *scriptstr,*musigstr; uint8_t msg[32]; CTransaction vintx; uint256 prevhash,hashBlock; int32_t n,numvouts; CTxOut vout; secp256k1_schnorrsig musig;
if ( ctx == 0 )
ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n == 3 )
{

View File

@@ -657,7 +657,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue result(UniValue::VOBJ); std::string rawtx; CPubKey roguepk,mypk; char *jsonstr; uint64_t inputsum,change,required,buyin=0; int32_t i,n,maxplayers = 1;
if ( txfee == 0 )
txfee = 10000;
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -693,7 +693,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
UniValue result(UniValue::VOBJ); std::vector<uint8_t> playerdata; uint256 playertxid,tokenid,origplayergame;int32_t n; CPubKey pk; bits256 t; std::string symbol,pname;
result.push_back(Pair("result","success"));
rogue_univalue(result,"playerinfo",-1,-1);
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -723,7 +723,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
roguepk = GetUnspendable(cp,0);
rogue_univalue(result,"register",-1,-1);
playertxid = tokenid = zeroid;
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -803,7 +803,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
if ( txfee == 0 )
txfee = 10000;
rogue_univalue(result,"keystrokes",-1,-1);
if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 )
{
gametxid = juint256(jitem(params,0));
result.push_back(Pair("gametxid",gametxid.GetHex()));
@@ -896,7 +896,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
roguepk = GetUnspendable(cp,0);
result.push_back(Pair("name","rogue"));
result.push_back(Pair("method","extract"));
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -968,7 +968,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
funcid = 'H';
mult = 200000;
}
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -1081,7 +1081,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,gameheight,maxplayers,numvouts; uint256 txid; CTransaction tx; int64_t buyin; uint64_t seed; bits256 t; char myrogueaddr[64]; CPubKey mypk,roguepk;
result.push_back(Pair("name","rogue"));
result.push_back(Pair("method","gameinfo"));
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{
@@ -1212,7 +1212,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
UniValue result(UniValue::VOBJ); int32_t n; char *namestr = 0;
rogue_univalue(result,"setname",-1,-1);
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 0 )
{

View File

@@ -2817,7 +2817,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
good = 0;
if ( params != 0 )
{
if ( (params= cclib_reparse(&n,params)) != 0 )
if ( params != 0 && (n= cJSON_GetArraySize()) > 0 )
{
if ( n > 2 && n <= (sizeof(timestamps)/sizeof(*timestamps))+2 )
{