Skip to content

Commit

Permalink
osd/PGLog: trim - avoid dereferencing invalid iter
Browse files Browse the repository at this point in the history
Log(e.g., projected_log) could theoretically be emtpy and hence there might
be potential access violation.

Signed-off-by: xie xingguo <[email protected]>
  • Loading branch information
xiexingguo committed Aug 18, 2018
1 parent 0ef08e1 commit 19a5c37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/osd/PGLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ void PGLog::IndexedLog::trim(

// reset complete_to to the beginning of the log
if (reset_complete_to) {
lgeneric_subdout(cct, osd, 20) << " moving complete_to " << " to "
<< log.begin()->version << dendl;
complete_to = log.begin();
if (complete_to != log.end()) {
lgeneric_subdout(cct, osd, 20) << " moving complete_to to "
<< log.begin()->version << dendl;
} else {
lgeneric_subdout(cct, osd, 20) << " log is now empty" << dendl;
}
}
}

Expand Down

0 comments on commit 19a5c37

Please sign in to comment.