Skip to content

Commit 4c38a87

Browse files
authored
Merge pull request #26 from quarkslab/fix_fake_chunk
Consider the first chunk that we encounter as valid
2 parents abbc6e3 + 29e6946 commit 4c38a87

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

include/quokka/Layout.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ class HeadIterator {
271271
/**
272272
* Retrieve the next chunk address if any are found
273273
* @param address Address to start from
274+
* @param skip_current Do not consider the chunk starting at the current
275+
* address
274276
*/
275-
void SetNextChunk(ea_t address);
277+
void SetNextChunk(ea_t address, bool skip_current = true);
276278

277279
/**
278280
* Compute the next address and state

src/Layout.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,24 @@ void HeadIterator::InitAddresses(ea_t address) {
6161
this->next_unk_addr = next_unknown(address, this->max_ea);
6262
this->next_head_addr = next_head(address, this->max_ea);
6363

64-
this->SetNextChunk(address);
64+
this->SetNextChunk(address, false);
6565
}
6666

67-
void HeadIterator::SetNextChunk(ea_t address) {
68-
func_t* func = get_next_fchunk(address);
67+
void HeadIterator::SetNextChunk(ea_t address, bool skip_current /* = true*/) {
68+
func_t* func;
69+
70+
// Check if there is a chunk starting at provided address
71+
if (!skip_current) {
72+
func = get_fchunk(address);
73+
if (func != nullptr && func->start_ea == address) {
74+
this->next_chunk_addr = address;
75+
this->next_func_chunk = func;
76+
return;
77+
}
78+
}
79+
80+
// Find the next chunk, not considering the one at the current address
81+
func = get_next_fchunk(address);
6982
if (func != nullptr) {
7083
this->next_chunk_addr = func->start_ea;
7184
this->next_func_chunk = func;

0 commit comments

Comments
 (0)