-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix insecureAPI, NonLocalizedStringChecker, NewDeleteLeaks macOS clang errors #31333
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
#include "flutter/fml/synchronization/waitable_event.h" | ||
|
||
#include <stdlib.h> | ||
#include <atomic> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
@@ -31,7 +32,7 @@ void SleepFor(TimeDelta duration) { | |
|
||
void EpsilonRandomSleep() { | ||
TimeDelta duration = | ||
TimeDelta::FromMilliseconds(static_cast<unsigned>(rand()) % 20u); | ||
TimeDelta::FromMilliseconds(static_cast<unsigned>(arc4random()) % 20u); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't matter for these unit tests, but can't hurt.
|
||
SleepFor(duration); | ||
} | ||
|
||
|
@@ -73,7 +74,7 @@ TEST(AutoResetWaitableEventTest, MultipleWaiters) { | |
std::vector<std::thread> threads; | ||
for (size_t j = 0u; j < 4u; j++) { | ||
threads.push_back(std::thread([&ev, &wake_count]() { | ||
if (rand() % 2 == 0) { | ||
if (arc4random() % 2 == 0) { | ||
ev.Wait(); | ||
} else { | ||
EXPECT_FALSE(ev.WaitWithTimeout(kActionTimeout)); | ||
|
@@ -158,7 +159,7 @@ TEST(ManualResetWaitableEventTest, SignalMultiple) { | |
threads.push_back(std::thread([&ev]() { | ||
EpsilonRandomSleep(); | ||
|
||
if (rand() % 2 == 0) { | ||
if (arc4random() % 2 == 0) { | ||
ev.Wait(); | ||
} else { | ||
EXPECT_FALSE(ev.WaitWithTimeout(kActionTimeout)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,12 +166,12 @@ static uint64_t GetLogicalKeyForEvent(NSEvent* event, uint64_t physicalKey) { | |
uint32_t* keyLabel = DecodeUtf16(keyLabelUtf16, &keyLabelLength); | ||
if (keyLabelLength == 1) { | ||
uint32_t keyLabelChar = *keyLabel; | ||
delete[] keyLabel; | ||
NSCAssert(!IsControlCharacter(keyLabelChar) && !IsUnprintableKey(keyLabelChar), | ||
@"Unexpected control or unprintable keylabel 0x%x", keyLabelChar); | ||
NSCAssert(keyLabelChar <= 0x10FFFF, @"Out of range keylabel 0x%x", keyLabelChar); | ||
character = keyLabelChar; | ||
} | ||
delete[] keyLabel; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
if (character != 0) { | ||
return KeyOfPlane(toLower(character), kUnicodePlane); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ - (instancetype)initWithEvent:(const FlutterKeyEvent*)event | |
if (event->character != nullptr) { | ||
size_t len = strlen(event->character); | ||
char* character = new char[len + 1]; | ||
strcpy(character, event->character); | ||
strlcpy(character, event->character, sizeof(character)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't matter for this unit test, but can't hurt.
|
||
_data->character = character; | ||
} | ||
_callback = callback; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,7 +220,12 @@ | |
FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project]; | ||
[viewController loadView]; | ||
[engine setViewController:viewController]; | ||
|
||
// Unit test localization is unnecessary. | ||
// NOLINTBEGIN(clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
viewController.textInputPlugin.string = @"textfield"; | ||
// NOLINTEND(clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker) | ||
|
||
// Creates a NSWindow so that the native text field can become first responder. | ||
NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) | ||
styleMask:NSBorderlessWindowMask | ||
|
@@ -291,4 +296,4 @@ | |
EXPECT_EQ([native_text_field.stringValue isEqualToString:@"textfield"], YES); | ||
} | ||
|
||
} // flutter::testing | ||
} // namespace flutter::testing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just a warning, but fix it anyway:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why isn't this
include
sufficient?https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8822761656441545457/+/u/build_host_debug_unopt/stdout