Changeset 170513 in webkit


Ignore:
Timestamp:
Jun 26, 2014, 6:10:48 PM (11 years ago)
Author:
ddkilzer@apple.com
Message:

[Win] Always NULL-terminate the string in createUTF8String()
<http://webkit.org/b/134353>
<rdar://problem/17471783>

Reviewed by Brent Fulgham.

  • plugins/PluginView.cpp:

(WebCore::createUTF8String): Pull out CString length into local
variable. Switch to use memcpy. Always NULL-terminate the
string.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r170512 r170513  
     12014-06-26  David Kilzer  <ddkilzer@apple.com>
     2
     3        [Win] Always NULL-terminate the string in createUTF8String()
     4        <http://webkit.org/b/134353>
     5        <rdar://problem/17471783>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * plugins/PluginView.cpp:
     10        (WebCore::createUTF8String): Pull out CString length into local
     11        variable.  Switch to use memcpy.  Always NULL-terminate the
     12        string.
     13
    1142014-06-26  Jer Noble  <jer.noble@apple.com>
    215
  • trunk/Source/WebCore/plugins/PluginView.cpp

    r170025 r170513  
    410410{
    411411    CString cstr = str.utf8();
    412     char* result = reinterpret_cast<char*>(fastMalloc(cstr.length() + 1));
    413 
    414     strncpy(result, cstr.data(), cstr.length() + 1);
     412    const size_t cstrLength = cstr.length();
     413    char* result = reinterpret_cast<char*>(fastMalloc(cstrLength + 1));
     414
     415    memcpy(result, cstr.data(), cstrLength);
     416    result[cstrLength] = '\0';
    415417
    416418    return result;
Note: See TracChangeset for help on using the changeset viewer.