diff options
author | sra@chromium.org <sra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 19:12:32 +0000 |
---|---|---|
committer | sra@chromium.org <sra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 19:12:32 +0000 |
commit | 077d7bd678054e21c36d7c569f3041aae8b4267f (patch) | |
tree | ed030da10cfe96fca5817e72af9eab9f7467fae0 /courgette | |
parent | 776f67ff177c12ba85f2095c8930ab90c577c79b (diff) | |
download | chromium_src-077d7bd678054e21c36d7c569f3041aae8b4267f.zip chromium_src-077d7bd678054e21c36d7c569f3041aae8b4267f.tar.gz chromium_src-077d7bd678054e21c36d7c569f3041aae8b4267f.tar.bz2 |
When iterating over the sections in a file, omit sections that have no raw data in the file.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/113917
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette')
-rw-r--r-- | courgette/image_info.cc | 10 | ||||
-rw-r--r-- | courgette/image_info.h | 3 |
2 files changed, 8 insertions, 5 deletions
diff --git a/courgette/image_info.cc b/courgette/image_info.cc index 5651f36..ed42f12 100644 --- a/courgette/image_info.cc +++ b/courgette/image_info.cc @@ -58,10 +58,12 @@ const Section* PEInfo::FindNextSection(uint32 fileOffset) const { const Section* best = 0; for (int i = 0; i < number_of_sections_; i++) { const Section* section = §ions_[i]; - if (fileOffset <= section->file_offset_of_raw_data) { - if (best == 0 || - section->file_offset_of_raw_data < best->file_offset_of_raw_data) { - best = section; + if (section->size_of_raw_data > 0) { // i.e. has data in file. + if (fileOffset <= section->file_offset_of_raw_data) { + if (best == 0 || + section->file_offset_of_raw_data < best->file_offset_of_raw_data) { + best = section; + } } } } diff --git a/courgette/image_info.h b/courgette/image_info.h index 53a0be7..17936e1 100644 --- a/courgette/image_info.h +++ b/courgette/image_info.h @@ -119,7 +119,8 @@ class PEInfo { return start_ + offset; } - // Finds the first section at file_offset or above. + // Finds the first section at file_offset or above. Does not return sections + // that have no raw bytes in the file. const Section* FindNextSection(uint32 file_offset) const; // Returns Section containing the relative virtual address, or NULL if none. const Section* RVAToSection(RVA rva) const; |