diff options
| author | potatoalienof13 <potatoalienof13@gmail.com> | 2022-12-22 17:34:42 -0500 |
|---|---|---|
| committer | potatoalienof13 <potatoalienof13@gmail.com> | 2022-12-22 17:34:42 -0500 |
| commit | 293d46837d1d28e40f3d0ddf21c653aa616bbf40 (patch) | |
| tree | e2270e82db44c9288485f4fa48513c16d28c9f8b /src/buffer.cc | |
| parent | 86bd4efd258a3e51245f5a6fcca9ee19790dee6e (diff) | |
Fix Buffer::advance out of bounds access.
This commit fixes a bug in Buffer::advance where it would first access
m_lines[-1], and then check whether or not that access would have
segfaulted. This commit moves the check to before the segfault would
occur.
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index fd8e0c4c..c968690f 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -575,9 +575,9 @@ BufferCoord Buffer::advance(BufferCoord coord, ByteCount count) const count += coord.column; while (count < 0) { - count += m_lines[--line].length(); - if (line < 0) + if (--line < 0) return {0, 0}; + count += m_lines[line].length(); } return { line, count }; } |
