mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
fix(coverity/510275): linematch out of bounds access (#30687)
Problem:
Int pointer cast to unsigned long pointer causes potential memory
corruption.
Solution:
Cast and store value first, then pass the new pointer.
(cherry picked from commit 60e1862ccb
)
This commit is contained in:
parent
ee7885aa21
commit
c257fe5582
@ -149,7 +149,9 @@ static int count_n_matched_chars(mmfile_t **sp, const size_t n, bool iwhite)
|
|||||||
mmfile_t fastforward_buf_to_lnum(mmfile_t s, linenr_T lnum)
|
mmfile_t fastforward_buf_to_lnum(mmfile_t s, linenr_T lnum)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < lnum - 1; i++) {
|
for (int i = 0; i < lnum - 1; i++) {
|
||||||
s.ptr = strnchr(s.ptr, (size_t *)&s.size, '\n');
|
size_t n = (size_t)s.size;
|
||||||
|
s.ptr = strnchr(s.ptr, &n, '\n');
|
||||||
|
s.size = (int)n;
|
||||||
if (!s.ptr) {
|
if (!s.ptr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user