Removed
Link Here
|
1 |
--- src/logfile.cc.orig 2020-09-09 16:17:12 UTC |
2 |
+++ src/logfile.cc |
3 |
@@ -323,10 +323,13 @@ logfile::rebuild_result_t logfile::rebuild_index() |
4 |
|
5 |
this->lf_line_buffer.clear(); |
6 |
if (!this->lf_index.empty()) { |
7 |
- off_t check_line_off = this->lf_index.back().get_offset(); |
8 |
+ auto last_line = this->lf_index.end(); |
9 |
+ --last_line; |
10 |
+ off_t check_line_off = last_line->get_offset(); |
11 |
+ auto last_length = ssize_t(this->line_length(last_line, false)); |
12 |
|
13 |
auto read_result = this->lf_line_buffer.read_range({ |
14 |
- check_line_off, this->lf_index_size - check_line_off |
15 |
+ check_line_off, last_length |
16 |
}); |
17 |
|
18 |
if (read_result.isErr()) { |
19 |
@@ -553,7 +556,7 @@ filesystem::path logfile::get_path() const |
20 |
|
21 |
size_t logfile::line_length(logfile::iterator ll, bool include_continues) |
22 |
{ |
23 |
- iterator next_line = ll; |
24 |
+ auto next_line = ll; |
25 |
size_t retval; |
26 |
|
27 |
if (!include_continues && this->lf_next_line_cache) { |
28 |
@@ -570,6 +573,9 @@ size_t logfile::line_length(logfile::iterator ll, bool |
29 |
|
30 |
if (next_line == this->end()) { |
31 |
retval = this->lf_index_size - ll->get_offset(); |
32 |
+ if (retval > line_buffer::MAX_LINE_BUFFER_SIZE) { |
33 |
+ retval = line_buffer::MAX_LINE_BUFFER_SIZE; |
34 |
+ } |
35 |
if (retval > 0 && !this->lf_partial_line) { |
36 |
retval -= 1; |
37 |
} |