From c199f5b1227bafdaa831a9369119fdf6f92599ad Mon Sep 17 00:00:00 2001 From: Ivan Penkov Date: Sun, 31 Jan 2016 18:17:42 -0800 Subject: [PATCH] Remove use of deprecated CFURLCreateDataAndPropertiesFromResource function. Original change (https://codereview.chromium.org/1527363003/) was failing in CFReadStreamGetBuffer() call, so changed to CFReadStreamRead() to be more conservative. Patch provided by Scott Hancher. BUG= R=mark@chromium.org Review URL: https://codereview.chromium.org/1637433003 . --- src/client/mac/handler/minidump_generator.cc | 25 +++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index 7d6e81db..53406567 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -142,12 +142,25 @@ void MinidumpGenerator::GatherSystemInformation() { 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); + CFMutableDataRef data = NULL; + while (true) { + // Actual data file tests: Mac at 480 bytes and iOS at 413 bytes. + const CFIndex kMaxBufferLength = 1024; + UInt8 data_bytes[kMaxBufferLength]; + CFIndex num_bytes_read = + CFReadStreamRead(read_stream, data_bytes, kMaxBufferLength); + if (num_bytes_read < 0) { + if (data) { + CFRelease(data); + data = NULL; + } + break; + } else if (num_bytes_read == 0) { + break; + } else if (!data) { + data = CFDataCreateMutable(NULL, 0); + } + CFDataAppendBytes(data, data_bytes, num_bytes_read); } CFReadStreamClose(read_stream); CFRelease(read_stream);