diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2020-11-24 21:46:43 +0000 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-15 21:19:29 +0100 |
commit | bfeecd0b418cf03a974c57082f4fc647b90aef06 (patch) | |
tree | 1e7ffd77738dfe99ebc5eca0f57d7da97d884cfe /src/nvim/eval/typval.c | |
parent | 9095101743b2606fb1d5f7a5a1216f22d2fb2b4a (diff) | |
download | rneovim-bfeecd0b418cf03a974c57082f4fc647b90aef06.tar.gz rneovim-bfeecd0b418cf03a974c57082f4fc647b90aef06.tar.bz2 rneovim-bfeecd0b418cf03a974c57082f4fc647b90aef06.zip |
vim-patch:8.1.0736: code for Blob not sufficiently tested
Problem: Code for Blob not sufficiently tested.
Solution: Add more tests. Fix uncovered crash. Add test_null_blob().
https://github.com/vim/vim/commit/c0f5a78c15b194f23bedb82e6825e34f481e6532
eval0 and ex_echo's emsg-specific changes have already been ported.
These tests uncover another crash that was fixed in v8.1.0738.
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 86e43e0819..e689571788 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2174,13 +2174,17 @@ void tv_blob_unref(blob_T *const b) bool tv_blob_equal(const blob_T *const b1, const blob_T *const b2) FUNC_ATTR_WARN_UNUSED_RESULT { - if (b1 == NULL || b2 == NULL) { - return false; + const int len1 = tv_blob_len(b1); + const int len2 = tv_blob_len(b2); + + // empty and NULL are considered the same + if (len1 == 0 && len2 == 0) { + return true; } if (b1 == b2) { return true; } - if (tv_blob_len(b1) != tv_blob_len(b2)) { + if (len1 != len2) { return false; } |