[PATCH] [libc++] Use memcpy() instead of strcpy()

Howard Hinnant hhinnant at apple.com
Sat Jun 29 16:54:54 PDT 2013


On Jun 7, 2013, at 10:21 PM, Matthew Dempsky <matthew at dempsky.org> wrote:

> Same as stdexcept.cpp in libc++abi: we've already computed "len =
> strlen(msg)", so we can use memcpy() instead of strcpy().
> 
> Index: src/stdexcept.cpp
> ===================================================================
> --- src/stdexcept.cpp	(revision 183600)
> +++ src/stdexcept.cpp	(working copy)
> @@ -61,7 +61,7 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg)
>     c[0] = c[1] = len;
>     str_ += offset;
>     count() = 0;
> -    std::strcpy(const_cast<char*>(c_str()), msg);
> +    std::memcpy(const_cast<char*>(c_str()), msg, len + 1);
> }
> 
> inline

Thanks, Committed revision 185274.

Howard




More information about the cfe-commits mailing list