Commit f7c82132 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Base64 bad menu strings

If a string destined for a menu cannot be turned into a CFString,
base64 it to allow for diagnosis.

Bug: 1140620
Change-Id: I78447813c8cfa5cae92e3e02f693313faf5336ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2535553
Commit-Queue: Avi Drissman <avi@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827001}
parent 6f33fd10
......@@ -6,6 +6,7 @@
#include <stddef.h>
#include "base/base64.h"
#include "base/strings/sys_string_conversions.h"
@interface WebMenuRunner (PrivateAPI)
......@@ -44,6 +45,16 @@
}
NSString* title = base::SysUTF8ToNSString(item->label.value_or(""));
// https://crbug.com/1140620: SysUTF8ToNSString will return nil if the bits
// that it is passed cannot be turned into a CFString. If this nil value is
// passed to -[NSMenuItem addItemWithTitle:action:keyEquivalent], Chromium
// will crash. Therefore, for debugging, if the result is nil, substitute in
// the raw bytes, encoded for safety in base64, to allow for investigation.
if (!title) {
std::string base64;
base::Base64Encode(*item->label, &base64);
title = base::SysUTF8ToNSString(base64);
}
NSMenuItem* menuItem = [_menu addItemWithTitle:title
action:@selector(menuItemSelected:)
keyEquivalent:@""];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment