Bug 1162293 - Part 2: Fix string leak in logging code. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Thu, 07 May 2015 09:43:39 -0700
changeset 242787 93eded78def993603fd6b78f6a324e8b5c8273e2
parent 242786 830ce4e36b476c7731c0d9d801eb40c89ab521c8
child 242788 70ac70374cf793cad2b8231b10049fc50c239061
push id59506
push usererahm@mozilla.com
push dateThu, 07 May 2015 16:44:02 +0000
treeherdermozilla-inbound@93eded78def9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1162293
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162293 - Part 2: Fix string leak in logging code. r=froydnj If logging is enabled the result from |ToNewCString| will be leaked. Switched to |NS_LossyConvertUTF16toASCII| instead.
widget/cocoa/NativeKeyBindings.mm
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
@@ -235,17 +235,17 @@ NativeKeyBindings::Execute(const WidgetK
 
     if (PR_LOG_TEST(gNativeKeyBindingsLog, PR_LOG_ALWAYS)) {
       NSString* selectorString = NSStringFromSelector(selector);
       nsAutoString nsSelectorString;
       nsCocoaUtils::GetStringForNSString(selectorString, nsSelectorString);
 
       PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
         ("%p NativeKeyBindings::KeyPress, selector=%s",
-         this, ToNewCString(nsSelectorString)));
+         this, NS_LossyConvertUTF16toASCII(nsSelectorString).get()));
     }
 
     // Try to find a simple mapping in the hashtable
     Command geckoCommand = static_cast<Command>(mSelectorToCommand.Get(
       reinterpret_cast<struct objc_selector*>(selector)));
 
     if (geckoCommand) {
       geckoCommands.AppendElement(geckoCommand);