Menu

#2904 smf: clang reports the possibility of memory leakage

5.18.09
fixed
nobody
None
defect
smf
d
major
False
2018-08-30
2018-07-30
No

/opensaf-code/src/smf/smfd/SmfUtils.cc:705:7: Potential leak of memory pointed to by 'rollbackData' [cplusplus.NewDeleteLeaks]

Should delete allocated memory for rollbackData when execution is failed.

SmfRollbackData *rollbackData = NULL;
if (io_rollbackCcb != NULL) {
  rollbackData = new (std::nothrow) SmfRollbackData(io_rollbackCcb);
  if (rollbackData == NULL) {
    LOG_WA("%s: Failed to create SmfRollbackData C++ object, no memory",
           __FUNCTION__);
    result = SA_AIS_ERR_NO_MEMORY;
    break;
  }
}

// Verify the create descriptor for this operation and fill in the
// attributes
result = imm_operation->Execute(rollbackData);
if (result != SA_AIS_OK) {
  LOG_WA("%s: imm_operation->Execute Fail, %s", __FUNCTION__,
         saf_error(result));
  break;
}

Related

Wiki: ChangeLog-5.18.09

Discussion

  • Vu Minh Nguyen

    Vu Minh Nguyen - 2018-08-03
    • status: assigned --> review
     
  • Vu Minh Nguyen

    Vu Minh Nguyen - 2018-08-03
    • status: review --> fixed
    • assigned_to: Vu Minh Nguyen --> nobody
     
  • Vu Minh Nguyen

    Vu Minh Nguyen - 2018-08-03

    commit eb5a6d7821e1c44f616f429501f12da067ce5b0d (HEAD -> develop, origin/develop, ticket-2904)
    Author: Vu Minh Nguyen vu.m.nguyen@dektech.com.au
    Date: Fri Aug 3 09:26:38 2018 +0700

    smf: fix memory leak reported by clang [#2904]
    
    When SmfImmOperation::Execute() gets failed in SmfImmUtils::doImmOperations(),
    the allocated memory `rollbackData` is not deallocated.
    
     

Log in to post a comment.