Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 300592b

Browse files
authored
allows mallocmapping copies of size zero (#35803)
1 parent d782c33 commit 300592b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

fml/mapping.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class MallocMapping final : public Mapping {
160160
/// for `uint8_t` and `char`.
161161
template <typename T>
162162
static MallocMapping Copy(const T* begin, const T* end) {
163-
FML_DCHECK(end > begin);
163+
FML_DCHECK(end >= begin);
164164
size_t length = end - begin;
165165
return Copy(begin, length);
166166
}

fml/mapping_unittests.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ TEST(MallocMapping, IsDontNeedSafe) {
6060
ASSERT_FALSE(mapping.IsDontNeedSafe());
6161
}
6262

63+
TEST(MallocMapping, CopySizeZero) {
64+
char ch = 'a';
65+
MallocMapping mapping = MallocMapping::Copy(&ch, &ch);
66+
ASSERT_EQ(0u, mapping.GetSize());
67+
}
68+
6369
} // namespace fml

0 commit comments

Comments
 (0)