mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Ensure the loop in offset_of_next_item_fish_2_0 is executed.
This ensures that timestamp will be initialized.
This commit is contained in:
parent
ac7a461070
commit
fcb3f36065
1 changed files with 11 additions and 0 deletions
11
history.cpp
11
history.cpp
|
@ -413,6 +413,13 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
|||
bool has_timestamp = false;
|
||||
time_t timestamp;
|
||||
const char *interior_line;
|
||||
|
||||
/*
|
||||
* Ensure the loop is processed at least once. Otherwise,
|
||||
* timestamp is unitialized.
|
||||
*/
|
||||
bool processed_once = false;
|
||||
|
||||
for (interior_line = next_line(line_start, end - line_start);
|
||||
interior_line != NULL && ! has_timestamp;
|
||||
interior_line = next_line(interior_line, end - interior_line))
|
||||
|
@ -427,8 +434,12 @@ static size_t offset_of_next_item_fish_2_0(const char *begin, size_t mmap_length
|
|||
|
||||
/* Try parsing a timestamp from this line. If we succeed, the loop will break. */
|
||||
has_timestamp = parse_timestamp(interior_line, ×tamp);
|
||||
|
||||
processed_once = true;
|
||||
}
|
||||
|
||||
assert(processed_once);
|
||||
|
||||
/* Skip this item if the timestamp is past our cutoff. */
|
||||
if (has_timestamp && timestamp > cutoff_timestamp)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue