Skip to content

Commit

Permalink
mac: Fix a few memory leaks.
Browse files Browse the repository at this point in the history
All found by clang's static analyzer.

BUG=none

Review URL: https://codereview.chromium.org/12390058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185895 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Mar 4, 2013
1 parent 166dfbb commit d409e1d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
13 changes: 6 additions & 7 deletions chrome/browser/ui/cocoa/applescript/element_applescript.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ @implementation ElementAppleScript
// record referring to itself. You must call setContainer:property: before
// you can call this method.
- (NSScriptObjectSpecifier*)objectSpecifier {
return [[NSUniqueIDSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:
(NSScriptClassDescription*)[[self container] classDescription]
containerSpecifier:
[[self container] objectSpecifier]
key:[self containerProperty]
uniqueID:[self uniqueID]];
return [[[NSUniqueIDSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:
(NSScriptClassDescription*)[[self container] classDescription]
containerSpecifier:[[self container] objectSpecifier]
key:[self containerProperty]
uniqueID:[self uniqueID]] autorelease];
}

- (void)setContainer:(id)value property:(NSString*)property {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ - (void)performLayout {
NSView* contentView = [[self window] contentView];
ResourceBundle& rb = ResourceBundle::GetSharedInstance();

textField_ =
[[PasswordGenerationTextField alloc]
initWithFrame:NSMakeRect(kBorderSize,
kBorderSize,
kTextFieldWidth,
kTextFieldHeight + kTextFieldTopPadding)
withController:self
normalImage:rb.GetNativeImageNamed(IDR_RELOAD_DIMMED).ToNSImage()
hoverImage:rb.GetNativeImageNamed(IDR_RELOAD).ToNSImage()];
textField_ = [[[PasswordGenerationTextField alloc]
initWithFrame:NSMakeRect(kBorderSize,
kBorderSize,
kTextFieldWidth,
kTextFieldHeight + kTextFieldTopPadding)
withController:self
normalImage:rb.GetNativeImageNamed(IDR_RELOAD_DIMMED).ToNSImage()
hoverImage:rb.GetNativeImageNamed(IDR_RELOAD)
.ToNSImage()] autorelease];
gfx::Font smallBoldFont =
rb.GetFont(ResourceBundle::SmallFont).DeriveFont(0, gfx::Font::BOLD);
[textField_ setFont:smallBoldFont.GetNativeFont()];
Expand All @@ -360,12 +360,12 @@ - (void)performLayout {
[button setAction:@selector(fillPassword:)];
[contentView addSubview:button];

NSTextField* title = [[NSTextField alloc]
scoped_nsobject<NSTextField> title([[NSTextField alloc]
initWithFrame:NSMakeRect(
kBorderSize,
kBorderSize + kTextFieldHeight + kVerticalSpacing,
kTitleWidth,
kTitleHeight)];
kTitleHeight)]);
[title setEditable:NO];
[title setBordered:NO];
[title setStringValue:l10n_util::GetNSString(
Expand Down
4 changes: 3 additions & 1 deletion skia/ext/skia_utils_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ SkBitmap NSImageRepToSkBitmap(
bitmap_.allocPixels();
bitmap_.eraseColor(0);
}
base::mac::ScopedCFTypeRef<CGColorSpaceRef> colorSpace(
CGColorSpaceCreateDeviceRGB());
cgContext_ = CGBitmapContextCreate(bitmap_.getPixels(), bitmap_.width(),
bitmap_.height(), 8, bitmap_.rowBytes(), CGColorSpaceCreateDeviceRGB(),
bitmap_.height(), 8, bitmap_.rowBytes(), colorSpace,
kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);

// Apply device matrix.
Expand Down
3 changes: 2 additions & 1 deletion ui/gfx/color_profile_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace gfx {

void ReadColorProfile(std::vector<char>* profile) {
CGColorSpaceRef monitor_color_space(base::mac::GetSystemColorSpace());
CFDataRef icc_profile(CGColorSpaceCopyICCProfile(monitor_color_space));
base::mac::ScopedCFTypeRef<CFDataRef> icc_profile(
CGColorSpaceCopyICCProfile(monitor_color_space));
if (icc_profile) {
size_t length = CFDataGetLength(icc_profile);
if (length > gfx::kMaxProfileLength)
Expand Down

0 comments on commit d409e1d

Please sign in to comment.