Remove use of deprecated CFURLCreateDataAndPropertiesFromResource function.

Patch by Scott Hancher

BUG=
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1527363003 .
This commit is contained in:
Ivan Penkov 2015-12-18 10:26:21 -08:00
parent 524508ff2f
commit 1be3027941

View file

@ -133,25 +133,34 @@ void MinidumpGenerator::GatherSystemInformation() {
vers_path, vers_path,
kCFURLPOSIXPathStyle, kCFURLPOSIXPathStyle,
false); false);
CFDataRef data; CFReadStreamRef read_stream = CFReadStreamCreateWithFile(NULL, sys_vers);
SInt32 error; CFRelease(sys_vers);
CFURLCreateDataAndPropertiesFromResource(NULL, sys_vers, &data, NULL, NULL, if (!read_stream) {
&error); return;
}
if (!data) { if (!CFReadStreamOpen(read_stream)) {
CFRelease(sys_vers); CFRelease(read_stream);
return;
}
CFDataRef data = NULL;
CFIndex num_bytes_read = 0;
const UInt8 *data_bytes =
CFReadStreamGetBuffer(read_stream, 0, &num_bytes_read);
if (data_bytes) {
data = CFDataCreate(NULL, data_bytes, num_bytes_read);
}
CFReadStreamClose(read_stream);
CFRelease(read_stream);
if (!data) {
return; return;
} }
CFDictionaryRef list = static_cast<CFDictionaryRef> CFDictionaryRef list = static_cast<CFDictionaryRef>
(CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable,
NULL)); NULL));
CFRelease(data);
if (!list) { if (!list) {
CFRelease(sys_vers);
CFRelease(data);
return; return;
} }
CFStringRef build_version = static_cast<CFStringRef> CFStringRef build_version = static_cast<CFStringRef>
(CFDictionaryGetValue(list, CFSTR("ProductBuildVersion"))); (CFDictionaryGetValue(list, CFSTR("ProductBuildVersion")));
CFStringRef product_version = static_cast<CFStringRef> CFStringRef product_version = static_cast<CFStringRef>
@ -160,8 +169,6 @@ void MinidumpGenerator::GatherSystemInformation() {
string product_str = ConvertToString(product_version); string product_str = ConvertToString(product_version);
CFRelease(list); CFRelease(list);
CFRelease(sys_vers);
CFRelease(data);
strlcpy(build_string_, build_str.c_str(), sizeof(build_string_)); strlcpy(build_string_, build_str.c_str(), sizeof(build_string_));