mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
PVS/V547: diff.c: xmalloc() never returns NULL
Normally we consider OOM to be fatal, but the diff module has extra functionality to handle OOM in case huge files are compared. Use try_malloc instead of xmalloc in that case.
This commit is contained in:
parent
a1e97b18f1
commit
6a432d4a0d
@ -695,7 +695,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din)
|
||||
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
|
||||
len += (long)STRLEN(ml_get_buf(buf, lnum, false)) + 1;
|
||||
}
|
||||
ptr = xmalloc(len);
|
||||
ptr = try_malloc(len);
|
||||
if (ptr == NULL) {
|
||||
// Allocating memory failed. This can happen, because we try to read
|
||||
// the whole buffer text into memory. Set the failed flag, the diff
|
||||
@ -1088,9 +1088,6 @@ static int diff_file(diffio_T *dio)
|
||||
const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
|
||||
+ STRLEN(p_srr) + 27);
|
||||
char *const cmd = xmalloc(len);
|
||||
if (cmd == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// We don't want $DIFF_OPTIONS to get in the way.
|
||||
if (os_getenv("DIFF_OPTIONS")) {
|
||||
|
Loading…
Reference in New Issue
Block a user