Bug 118155

Summary: Add a new String::charactersWithNullTermination() function that returns a vector
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, eric.carlson, galpeter, glenn, jer.noble
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch kling: review+

Description Anders Carlsson 2013-06-27 16:36:21 PDT
Add a new String::charactersWithNullTermination() function that returns a vector
Comment 1 Anders Carlsson 2013-06-27 16:38:59 PDT
Created attachment 205646 [details]
Patch
Comment 2 WebKit Commit Bot 2013-06-27 16:41:12 PDT
Attachment 205646 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WTF/ChangeLog', u'Source/WTF/wtf/text/WTFString.cpp', u'Source/WTF/wtf/text/WTFString.h', u'Source/WebCore/ChangeLog', u'Source/WebCore/platform/graphics/win/FontCacheWin.cpp', u'Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp', u'Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp', u'Source/WebCore/platform/graphics/win/IconWin.cpp', u'Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp', u'Source/WebCore/platform/graphics/wince/FontPlatformData.cpp', u'Source/WebCore/platform/network/curl/CurlDownload.cpp', u'Source/WebCore/platform/network/win/CookieJarWin.cpp', u'Source/WebCore/platform/network/win/DownloadBundleWin.cpp', u'Source/WebCore/platform/network/win/ResourceHandleWin.cpp', u'Source/WebCore/platform/text/win/LocaleWin.cpp', u'Source/WebCore/platform/text/win/TextCodecWin.cpp', u'Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp', u'Source/WebCore/platform/win/ContextMenuWin.cpp', u'Source/WebCore/platform/win/DragImageWin.cpp', u'Source/WebCore/platform/win/FileSystemWin.cpp', u'Source/WebCore/platform/win/MIMETypeRegistryWin.cpp', u'Source/WebCore/platform/win/PasteboardWin.cpp', u'Source/WebCore/platform/win/PathWalker.cpp', u'Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp', u'Source/WebCore/platform/win/SharedBufferWin.cpp', u'Source/WebCore/platform/wince/FileSystemWinCE.cpp', u'Source/WebCore/plugins/win/PluginDatabaseWin.cpp', u'Source/WebCore/plugins/win/PluginPackageWin.cpp', u'Source/WebCore/plugins/win/PluginViewWin.cpp']" exit_code: 1
Source/WebCore/platform/network/win/ResourceHandleWin.cpp:310:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/plugins/win/PluginViewWin.cpp:900:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/WebCore/platform/graphics/win/FontCacheWin.cpp:103:  Use 0 instead of NULL.  [readability/null] [5]
Source/WebCore/platform/graphics/win/FontCacheWin.cpp:105:  Use 0 instead of NULL.  [readability/null] [5]
Total errors found: 4 in 29 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Andreas Kling 2013-06-27 17:14:27 PDT
Comment on attachment 205646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=205646&action=review

> Source/WTF/wtf/text/WTFString.cpp:401
> +    if (m_impl) {

No early return?
Comment 4 Anders Carlsson 2013-06-27 17:20:20 PDT
Committed r152142: <http://trac.webkit.org/changeset/152142>
Comment 5 Brent Fulgham 2013-07-19 11:54:54 PDT
Comment on attachment 205646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=205646&action=review

These changes broke a few things on Windows.  I'll correct under a separate bug.

> Source/WebCore/platform/win/ContextMenuWin.cpp:126
> +            menuItem.dwTypeData = const_cast<LPWSTR>(itemTitle.charactersWithNullTermination().data());

This definitely breaks things due to asking the menuItem to display a (possibly re-used) temporary memory address.

> Source/WebCore/platform/win/PasteboardWin.cpp:966
> +        LPCWSTR localPathStr = localPath.charactersWithNullTermination().data();

I think this might break things, because we are using the address of a temporary.

> Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp:71
> +        requestInfo.pwszChallengeString = const_cast<wchar_t*>(localChallenge.charactersWithNullTermination().data());

Holding onto the address of a temporary!