From 2e86dfe70513091a0fb8f5725a4c81c476f993e8 Mon Sep 17 00:00:00 2001
From: ladderbreaker <ladderbreaker@4c0a9323-5329-0410-9bdc-e9ce6186880e>
Date: Wed, 6 Jun 2007 20:49:48 +0000
Subject: [PATCH] issue 154: reviewed by Waylonis

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@187 4c0a9323-5329-0410-9bdc-e9ce6186880e
---
 src/common/mac/macho_id.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/common/mac/macho_id.cc b/src/common/mac/macho_id.cc
index c45329ed..728bd47e 100644
--- a/src/common/mac/macho_id.cc
+++ b/src/common/mac/macho_id.cc
@@ -275,7 +275,11 @@ bool MachoID::WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
       if (swap)
         swap_section(&sec, 1, NXHostByteOrder());
 
-      macho_id->Update(walker, header_offset + sec.offset, sec.size);
+      // sections of type S_ZEROFILL are "virtual" and contain no data
+      // in the file itself
+      if ((sec.flags & SECTION_TYPE) != S_ZEROFILL && sec.offset != 0)
+        macho_id->Update(walker, header_offset + sec.offset, sec.size);
+
       offset += sizeof(struct section);
     }
   } else if (cmd->cmd == LC_SEGMENT_64) {
@@ -304,7 +308,11 @@ bool MachoID::WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
       if (swap)
         breakpad_swap_section_64(&sec64, 1, NXHostByteOrder());
 
-      macho_id->Update(walker, header_offset + sec64.offset, sec64.size);
+      // sections of type S_ZEROFILL are "virtual" and contain no data
+      // in the file itself
+      if ((sec64.flags & SECTION_TYPE) != S_ZEROFILL && sec64.offset != 0)
+        macho_id->Update(walker, header_offset + sec64.offset, sec64.size);
+
       offset += sizeof(struct section_64);
     }
   }