diff --git a/fml/mapping.h b/fml/mapping.h index 3bf50841cd130..c6fe0151eff79 100644 --- a/fml/mapping.h +++ b/fml/mapping.h @@ -160,7 +160,7 @@ class MallocMapping final : public Mapping { /// for `uint8_t` and `char`. template 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); } diff --git a/fml/mapping_unittests.cc b/fml/mapping_unittests.cc index 7dc397dbde14e..f0b2a992d18ca 100644 --- a/fml/mapping_unittests.cc +++ b/fml/mapping_unittests.cc @@ -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