[cfe-dev] [patch] added a _LIBCPP_ASSERT to std::string::__init( __first, __last ) to ensure [__first,__last] is valid

via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 19 11:12:07 PDT 2016


Hello.
Currently, std::string::string( it_first, it_last ) does not check that 
the range is valid, which results in a very huge memory reservation. 
This reservation might result in an immediate throw, but depending on 
OSes and/or OSes'configuration (overcommit parameters on linux *might* 
avoid the throw, for exemple) it could also only lead to a crash far 
than the source of the problem.

This patch simply adds an assertion to be sure that the range is valid 
(distance(last,first)>=0) when explicitly asked by the developer 
(therefore).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_string_init
Type: text/x-diff
Size: 2076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160919/6ba69902/attachment.diff>


More information about the cfe-dev mailing list