bug 763621 - Fix a Breakpad issue, patch from upstream r792. r=upstream a=lsblakk
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 18 Jul 2012 15:11:51 -0400
changeset 100527 d15738db65a4a7648d2a30ce6a98daf9d462a9b3
parent 100522 65cd4f678ab0a05f3e8c2d74e25baa2287746699
child 100529 647a14077a3eb41f0b691f0b7bc0c21a54576b4c
push idunknown
push userunknown
push dateunknown
reviewersupstream, lsblakk
bugs763621
milestone15.0
bug 763621 - Fix a Breakpad issue, patch from upstream r792. r=upstream a=lsblakk
toolkit/crashreporter/google-breakpad/src/client/linux/minidump_writer/minidump_writer.cc
--- a/toolkit/crashreporter/google-breakpad/src/client/linux/minidump_writer/minidump_writer.cc
+++ b/toolkit/crashreporter/google-breakpad/src/client/linux/minidump_writer/minidump_writer.cc
@@ -1303,16 +1303,25 @@ popline:
 
     if (!total)
       return false;
 
     UntypedMDRVA memory(&minidump_writer_);
     if (!memory.Allocate(total))
       return false;
     for (MDRVA pos = memory.position(); buffers; buffers = buffers->next) {
+      // Check for special case of a zero-length buffer.  This should only
+      // occur if a file's size happens to be a multiple of the buffer's
+      // size, in which case the final sys_read() will have resulted in
+      // zero bytes being read after the final buffer was just allocated.
+      if (buffers->len == 0) {
+        // This can only occur with final buffer.
+        assert(buffers->next == NULL);
+        continue;
+      }
       memory.Copy(pos, &buffers->data, buffers->len);
       pos += buffers->len;
     }
     *result = memory.location();
     return true;
   }
 
   bool WriteOSInformation(MDRawSystemInfo* sys_info) {