diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-07-29 04:53:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-29 04:53:40 +0200 |
commit | 5acda12419858da202ce7ea962fae75102a75b2b (patch) | |
tree | 065ffe0208ade991ec352d72f536075336c5880c /src | |
parent | 707bb3749459fb30c02701b63553af7a3460f980 (diff) | |
download | rneovim-5acda12419858da202ce7ea962fae75102a75b2b.tar.gz rneovim-5acda12419858da202ce7ea962fae75102a75b2b.tar.bz2 rneovim-5acda12419858da202ce7ea962fae75102a75b2b.zip |
coverity/155506: null dereference (#7089)
Coverity warning is a false positive: if rbuffer_read_ptr() returns
NULL then `cnt` is zero.
Revert 76ea97c809e50fccc5ca6615943ac6da1db1e030 (which caused
the TSan build to hang often--possibly because of the missing ui_flush()).
Instead, modify out_data_append_to_screen() to check for NULL.
ref #6862
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/os/shell.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 9d80a43718..32e9a70e57 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -447,7 +447,7 @@ static void out_data_append_to_screen(char *output, size_t remaining, size_t off = 0; int last_row = (int)Rows - 1; - while (off < remaining) { + while (output != NULL && off < remaining) { // Found end of line? if (output[off] == NL) { // Can we start a new line or do we need to continue the last one? @@ -473,7 +473,7 @@ static void out_data_append_to_screen(char *output, size_t remaining, off++; } - if (remaining) { + if (output != NULL && remaining) { if (last_col == 0) { screen_del_lines(0, 0, 1, (int)Rows, NULL); } @@ -496,12 +496,8 @@ static void out_data_cb(Stream *stream, RBuffer *buf, size_t count, void *data, size_t cnt; char *ptr = rbuffer_read_ptr(buf, &cnt); - if (ptr == NULL || cnt == 0) { - // Nothing to read; - return; - } - - if (out_data_decide_throttle(cnt)) { // Skip output above a threshold. + if (ptr != NULL && cnt > 0 + && out_data_decide_throttle(cnt)) { // Skip output above a threshold. // Save the skipped output. If it is the final chunk, we display it later. out_data_ring(ptr, cnt); } else { |