Project

General

Profile

Actions

Bug #1562

closed

In SecTpmOsx, call CFRelease to free memory

Added by Anonymous over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Category:
Base
Target version:
Start date:
04/30/2014
Due date:
% Done:

100%

Estimated time:

Description

In sec-tpm-osx.cpp, there are several calls to create memory, for example:
CFStringRef keyLabel = CFStringCreateWithCString(NULL, keyNameUri.c_str(), kCFStringEncodingUTF8);

https://github.com/named-data/ndn-cxx/blob/f56c68f66b19444e82397db6f1c10604ecb1e6dd/src/security/sec-tpm-osx.cpp#L834

In cases like this, the code should also call CFRelease(keyLabel) to release the memory. There could be a memory leak without it. Functions also need to free the allocated memory returned by SecTpmOsx::Impl::getKey.


Related issues 1 (0 open1 closed)

Blocks ndn-cxx - Task #1663: Check if there are memory leaks in SecTpmOsxRejected

Actions
Actions #1

Updated by Alex Afanasyev over 10 years ago

Isn't this CF* things are managed memory? If not, then there are a lot of problems there.

Actions #2

Updated by Alex Afanasyev over 10 years ago

  • Category set to Base
  • Assignee set to Yingdi Yu
  • Target version set to v0.2
Actions #3

Updated by Anonymous over 10 years ago

CFStringRef is just a C-style pointer. There is no automatic deallocation.

typedef const struct __CFString * CFStringRef;

"If you own an object, it is your responsibility to relinquish ownership (using CFRelease) when you have finished with it."

https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029

Actions #4

Updated by Anonymous over 10 years ago

Note that you need to use CFRelease for every call with "Create" in the name, including temporary values like CFNumberCreate here:

https://github.com/named-data/ndn-cxx/blob/f56c68f66b19444e82397db6f1c10604ecb1e6dd/src/security/sec-tpm-osx.cpp#L643

Actions #5

Updated by Alex Afanasyev over 10 years ago

  • Status changed from New to Resolved
  • Assignee changed from Yingdi Yu to Alex Afanasyev
  • % Done changed from 0 to 100

Additional memory leak checks needed before this issue can be fully closed.

Actions #6

Updated by Alex Afanasyev over 10 years ago

  • Blocks Task #1663: Check if there are memory leaks in SecTpmOsx added
Actions #7

Updated by Alex Afanasyev over 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF