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().
c0f5a78c15

eval0 and ex_echo's emsg-specific changes have already been ported.
These tests uncover another crash that was fixed in v8.1.0738.
This commit is contained in:
Sean Dewar
2020-11-24 21:46:43 +00:00
parent 9095101743
commit bfeecd0b41
4 changed files with 98 additions and 16 deletions

View File

@@ -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;
}