Skip to content

Commit 797a41b

Browse files
committed
Missed edge case when resizing the memorymapped file in UserDefault that could cause a crash
1 parent a3b89db commit 797a41b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/base/CCUserDefault.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ void UserDefault::flush()
484484
if (obs.length() > _curMapSize)
485485
{
486486
_rwmmap->unmap();
487-
_curMapSize <<= 1; // X2
487+
while (obs.length() > _curMapSize)
488+
_curMapSize <<= 1; // X2
489+
488490
posix_fsetsize(_fd, _curMapSize);
489491
_rwmmap->map(posix_fd2fh(_fd), 0, _curMapSize, error);
490492
}

0 commit comments

Comments
 (0)