allows mallocmapping copies of size zero (flutter/engine#35803)

This commit is contained in:
gaaclarke
2022-08-30 11:10:25 -07:00
committed by GitHub
parent d8080fb011
commit 7a54d02e79
2 changed files with 7 additions and 1 deletions

View File

@@ -160,7 +160,7 @@ class MallocMapping final : public Mapping {
/// for `uint8_t` and `char`.
template <typename T>
static MallocMapping Copy(const T* begin, const T* end) {
FML_DCHECK(end > begin);
FML_DCHECK(end >= begin);
size_t length = end - begin;
return Copy(begin, length);
}

View File

@@ -60,4 +60,10 @@ TEST(MallocMapping, IsDontNeedSafe) {
ASSERT_FALSE(mapping.IsDontNeedSafe());
}
TEST(MallocMapping, CopySizeZero) {
char ch = 'a';
MallocMapping mapping = MallocMapping::Copy(&ch, &ch);
ASSERT_EQ(0u, mapping.GetSize());
}
} // namespace fml