jeudi 25 mai 2023

malloc: Double free of object 0x7fbf95f18160 on string to uint64_t [closed]

I am trying to convert response I am getting from jsonrpc lib (string) to uint64_t but am getting malloc error. I am not allocating any memory myself so do not know what to look into exactly

uint64_t getBalance(jsonrpc::Client client, std::string address){
    Json::Value params;
    params.append(address);
    params.append("latest");

    Json::Value response = client.CallMethod("eth_getBalance", params);
    std::cout << response << std::endl;

    if (!response.isNull() && response.isString()) {
            return std::strtoull(response.asCString(), nullptr, 16);
    }

    return 0;
}

The above is my code and it gives me the following after correctly returning the value: rpcClient(21770,0x7ff8530d9680) malloc: Double free of object 0x7fbf95f18160 rpcClient(21770,0x7ff8530d9680) malloc: *** set a breakpoint in malloc_error_break to debug

I am calling the getBalance function in main and printing the balance on console. I am not catching the value in any variable, just calling the function in the std::cout line.

Aucun commentaire:

Enregistrer un commentaire