Chromium Code Reviews| Index: src/client/mac/handler/minidump_generator.cc |
| diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc |
| index 7d6e81dbb86439110b3106fffe9f31b7f2c70350..4e15e9c12252e34761db74ce80ac57f3cb6141d9 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); |
| + // Actual data file tests: Mac at 480 bytes and iOS at 413 bytes. |
| + const CFIndex kMaxBufferLength = 1024; |
|
Mark Mentovai
2016/02/01 01:03:36
You can move these two inside the loop.
ivanpe
2016/02/01 02:05:20
Done.
|
| + UInt8 data_bytes[kMaxBufferLength]; |
| + CFMutableDataRef data = NULL; |
| + while (true) { |
| + 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); |