Skip to content

Commit

Permalink
honey_compact: don't crash on empty tables
Browse files Browse the repository at this point in the history
If the table is empty, calling ->next will crash.  Checking ->empty
on the cursor instead avoids going down that codepath

Avoids a crasher in compacting when adding a Glass database
with nothing but metadata in it:

https://lists.xapian.org/pipermail/xapian-devel/2020-September/003384.html
  • Loading branch information
brong authored and rsto committed Oct 27, 2022
1 parent 8b606c7 commit c97dfba
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions xapian-core/backends/honey/honey_compact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,17 @@ merge_postlists(Xapian::Compactor* compactor,
priority_queue<cursor_type*, vector<cursor_type*>, gt_type> pq;
for ( ; b != e; ++b, ++offset) {
auto in = *b;
auto cursor = new cursor_type(in, *offset);
if (cursor->next()) {
pq.push(cursor);
} else {
if (in->empty()) {
delete in;
// Skip empty tables.
delete cursor;
}
} else {
auto cursor = new cursor_type(in, *offset);
if (cursor->next()) {
pq.push(cursor);
} else {
delete cursor;
}
}
}

string last_key;
Expand Down

0 comments on commit c97dfba

Please sign in to comment.