aitos-io / BoAT-X-Framework

BoAT-X Blockchain Application Framework for IoT
http://www.aitos.io
Apache License 2.0
926 stars 49 forks source link

http2Init return value should check NULL #1262

Open Cavalierliu opened 1 year ago

Cavalierliu commented 1 year ago

BoatHlfabricWallet BoatHlfabricWalletInit(BUINT8 keypairIndex, BUINT8 networkIndex) { BoatHlfabricWallet wallet_ptr = NULL; BOAT_RESULT result = BOAT_SUCCESS; // BUINT8 i = 0;

/* allocate wallet memory */
wallet_ptr = BoatMalloc(sizeof(BoatHlfabricWallet));
if (wallet_ptr == NULL)
{
    BoatLog(BOAT_LOG_CRITICAL, "Failed to malloc wallet memory.");
    return NULL;
}
result = BoATKeypair_GetKeypairByIndex(&(wallet_ptr->account_info.prikeyCtx), keypairIndex);
if (result != BOAT_SUCCESS)
{
    BoatLog(BOAT_LOG_CRITICAL, "get keypair by index fail");
    return NULL;
}
result = BoATHlfabric_GetNetworkByIndex(&(wallet_ptr->network_info), networkIndex);
if (result != BOAT_SUCCESS)
{
    BoatLog(BOAT_LOG_CRITICAL, "get network by index fail");
    return NULL;
}

if (BOAT_HLFABRIC_TLS_SUPPORT == 1)

wallet_ptr->tlsCAchain.ca.field_len = 0;
wallet_ptr->tlsCAchain.ca.field_ptr = NULL;

endif

wallet_ptr->http2Context_ptr = NULL;
/* network_info assignment */
// result += BoatHlfabricWalletSetNetworkInfo(wallet_ptr, config_ptr->nodesCfg);
/* http2Context_ptr assignment */
wallet_ptr->http2Context_ptr = http2Init();

if (result != BOAT_SUCCESS)
{
    BoatLog(BOAT_LOG_CRITICAL, "Failed to set accountInfo|TlsUInfo|networkInfo.");
    return NULL;
}

return wallet_ptr;

}