Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
!CHAOS Control System 149478 RESOURCE_LEAK Resource leaks good found memory leaks
File: /chaos/common/message/MDSMessageChannel.cpp
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! return last sendxxx error code
int32_t MDSMessageChannel::getLastErrorCode() {
    return MultiAddressMessageChannel::getLastErrorCode();
}

//! return last sendxxx error message
const std::string& MDSMessageChannel::getLastErrorMessage() {
    return MultiAddressMessageChannel::getLastErrorMessage();
}

//! return last sendxxx error domain
const std::string& MDSMessageChannel::getLastErrorDomain() {
    return MultiAddressMessageChannel::getLastErrorDomain();
}


//! Send heartbeat
/*!
 Send the heartbeat for an identification ID. This can be an id for a device or an uitoolkit instance
 \param identificationID identification id of a device or a client
 */
void MDSMessageChannel::sendHeartBeatForDeviceID(const std::string& identification_id) {
    std::auto_ptr<CDataWrapper> hb_message(new CDataWrapper());
    hb_message->addStringValue(NodeDefinitionKey::NODE_UNIQUE_ID, identification_id);
 << 1. Storage is returned from allocation function "release". [Note: The source code implementation of the function has been overridden by a builtin model.]
 << 2. Resource "hb_message.release()" is not freed or pointed-to in "sendMessage".
 <<< CID 149478: Resource leaks RESOURCE_LEAK
 <<< 3. Failing to save or free storage allocated by "hb_message.release()" leaks it.
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
    sendMessage(NodeDomainAndActionRPC::RPC_DOMAIN,
                ChaosSystemDomainAndActionLabel::MDS_CU_HEARTBEAT,
                hb_message.release());
}


//! Send unit server CU states to MDS
int MDSMessageChannel::sendUnitServerCUStates(CDataWrapper& deviceDataset,
                                              bool requestCheck,
                                              uint32_t millisec_to_wait) {
    int size_bson = 0;
    string currentBrokerIpPort;
    getRpcPublishedHostAndPort(currentBrokerIpPort);
    std::auto_ptr<CDataWrapper> data(new CDataWrapper(deviceDataset.getBSONRawData(size_bson)));
    data->addStringValue(NodeDefinitionKey::NODE_RPC_ADDR, currentBrokerIpPort);
    
    if(requestCheck){
        std::auto_ptr<MultiAddressMessageRequestFuture> request_future = sendRequestWithFuture(NodeDomainAndActionRPC::RPC_DOMAIN,
                                                                                               ChaosSystemDomainAndActionLabel::UNIT_SERVER_STATES_ANSWER,
                                                                                               data.release());
        request_future->setTimeout(millisec_to_wait);
        if(request_future->wait()) {
            DECODE_ERROR(request_future)
        } else {
            last_error_code = -1;
        }
    } else {
Events:
1. alloc_fn MDSMessageChannel.cpp:70
2. noescape MDSMessageChannel.cpp:70
3. leaked_storage MDSMessageChannel.cpp:70