Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Memory leak in Support\Windows\RWMutex.inc #21201

Closed Quuxplusone closed 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR21202
Status RESOLVED FIXED
Importance P normal
Reported by Ilyas (ilias@metaquotes.net)
Reported on 2014-10-08 04:21:01 -0700
Last modified on 2014-10-20 19:34:51 -0700
Version trunk
Hardware PC Windows NT
CC dblaikie@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
In RWMutexImpl constuctor (line 76)

  if (loadSRW()) {
    data_ = calloc(1, sizeof(SRWLOCK));
    fpInitializeSRWLock(static_cast<PSRWLOCK>(data_));
  } else {
    data_ = calloc(1, sizeof(CRITICAL_SECTION));
    InitializeCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
  }

memory is allocated in both cases, but in RWMutexImpl destructor (line 86)
memory is freed only in one case

RWMutexImpl::~RWMutexImpl() {
  if (sHasSRW) {
    // Nothing to do in the case of slim reader/writers
  } else {
    DeleteCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
    free(data_);
  }
}
Quuxplusone commented 9 years ago

Fixed in r220251