[libcxx-commits] [PATCH] D156783: [libc++] Fix `std::out_of_range` thrown from `basic_stringbuf::str() &&`
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 1 08:58:49 PDT 2023
Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.
Thanks for the quick fix! LGTM modulo a comment.
After you land the patch, can you put it up for backporting to LLVM-17?
(The instructions are here https://www.llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches)
================
Comment at: libcxx/include/sstream:405
+ if (!__view.empty())
+ __result.assign(std::move(__str_), __view.data() - __str_.data(), __view.size());
__str_.clear();
----------------
Depending on the order of evaluation `__view.data() - __str_.data()` may be used after `__str_` has been moved. Lets determine the size before `assign`. This is pre-existing.
Whether this is save depends on the order in which the function arguments are evaluated. Clang and GCC use a different order.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156783/new/
https://reviews.llvm.org/D156783
More information about the libcxx-commits
mailing list