mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge #10500 from ngortheone/pvs/V1028_misc1
This commit is contained in:
@@ -495,9 +495,14 @@ open_line (
|
|||||||
}
|
}
|
||||||
if (lead_len > 0) {
|
if (lead_len > 0) {
|
||||||
// allocate buffer (may concatenate p_extra later)
|
// allocate buffer (may concatenate p_extra later)
|
||||||
leader = xmalloc((size_t)(lead_len + lead_repl_len + extra_space
|
int bytes = lead_len
|
||||||
+ extra_len + (second_line_indent > 0
|
+ lead_repl_len
|
||||||
? second_line_indent : 0) + 1));
|
+ extra_space
|
||||||
|
+ extra_len
|
||||||
|
+ (second_line_indent > 0 ? second_line_indent : 0)
|
||||||
|
+ 1;
|
||||||
|
assert(bytes >= 0);
|
||||||
|
leader = xmalloc((size_t)bytes);
|
||||||
allocated = leader; // remember to free it later
|
allocated = leader; // remember to free it later
|
||||||
|
|
||||||
STRLCPY(leader, saved_line, lead_len + 1);
|
STRLCPY(leader, saved_line, lead_len + 1);
|
||||||
@@ -1556,11 +1561,14 @@ void ins_str(char_u *s)
|
|||||||
oldp = ml_get(lnum);
|
oldp = ml_get(lnum);
|
||||||
oldlen = (int)STRLEN(oldp);
|
oldlen = (int)STRLEN(oldp);
|
||||||
|
|
||||||
newp = (char_u *) xmalloc((size_t)(oldlen + newlen + 1));
|
newp = (char_u *)xmalloc((size_t)oldlen + (size_t)newlen + 1);
|
||||||
if (col > 0)
|
if (col > 0) {
|
||||||
memmove(newp, oldp, (size_t)col);
|
memmove(newp, oldp, (size_t)col);
|
||||||
|
}
|
||||||
memmove(newp + col, s, (size_t)newlen);
|
memmove(newp + col, s, (size_t)newlen);
|
||||||
memmove(newp + col + newlen, oldp + col, (size_t)(oldlen - col + 1));
|
int bytes = oldlen - col + 1;
|
||||||
|
assert(bytes >= 0);
|
||||||
|
memmove(newp + col + newlen, oldp + col, (size_t)bytes);
|
||||||
ml_replace(lnum, newp, false);
|
ml_replace(lnum, newp, false);
|
||||||
changed_bytes(lnum, col);
|
changed_bytes(lnum, col);
|
||||||
curwin->w_cursor.col += newlen;
|
curwin->w_cursor.col += newlen;
|
||||||
|
Reference in New Issue
Block a user