Bug #1562
closedIn SecTpmOsx, call CFRelease to free memory
100%
Description
In sec-tpm-osx.cpp, there are several calls to create memory, for example:
CFStringRef keyLabel = CFStringCreateWithCString(NULL, keyNameUri.c_str(), kCFStringEncodingUTF8);
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.
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.
Updated by Alex Afanasyev over 10 years ago
- Category set to Base
- Assignee set to Yingdi Yu
- Target version set to v0.2
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."
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:
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.
Updated by Alex Afanasyev over 10 years ago
- Blocks Task #1663: Check if there are memory leaks in SecTpmOsx added
Updated by Alex Afanasyev over 10 years ago
- Status changed from Resolved to Closed