This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

On second tought (was: Re: [PATCH] Avoid strtok for thread safety)


Nathan Myers wrote:

strpbrk() returns NULL if it doesn't find any of the characters
searched for.  What happens then?

Well, perhaps, thanks to Benjamin, the situation is not so bad...

That function begins like this:

 // Construct named _Impl.
 locale::_Impl::
 _Impl(const char* __s, size_t __refs)
 : _M_references(__refs), _M_facets_size(_GLIBCPP_NUM_FACETS)
 {
   // Initialize the underlying locale model, which also checks
   // to see if the given name is valid.
   __c_locale __cloc;
   locale::facet::_S_create_c_locale(__cloc, __s);
 ...

Therefore, S_create_c_locale takes the burden of cheking __s for us
*before* the fragile code...

Yeh!

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]