[libcxx-commits] [PATCH] D138798: [libc++][NFC] Add assertions before calling memmove
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 28 05:40:46 PST 2022
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Since we're checking preconditions for calling memmove, we might
as well do that properly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138798
Files:
libcxx/include/fstream
libcxx/include/locale
Index: libcxx/include/locale
===================================================================
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -4014,7 +4014,8 @@
else
{
if (__extbufend_ != __extbufnext_) {
- _LIBCPP_ASSERT(__extbufnext_ != NULL, "underflow moving from NULL" );
+ _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
+ _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
_VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
}
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
Index: libcxx/include/fstream
===================================================================
--- libcxx/include/fstream
+++ libcxx/include/fstream
@@ -754,7 +754,8 @@
else
{
if (__extbufend_ != __extbufnext_) {
- _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from NULL" );
+ _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
+ _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
_VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
}
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138798.478204.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221128/16a4fe4d/attachment.bin>
More information about the libcxx-commits
mailing list