Skip to content
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 potential crash in setTitle #1270

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,13 @@ - (void)dealloc
ASLogDebug(@"");

[decoratedWindow release]; decoratedWindow = nil;
[fullScreenWindow release]; fullScreenWindow = nil;
[windowAutosaveKey release]; windowAutosaveKey = nil;
[vimView release]; vimView = nil;
[toolbar release]; toolbar = nil;
// in case processAfterWindowPresentedQueue wasn't called
[afterWindowPresentedQueue release]; afterWindowPresentedQueue = nil;
[lastSetTitle release]; lastSetTitle = nil;

[super dealloc];
}
Expand Down Expand Up @@ -461,8 +463,9 @@ - (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state
- (void)setTitle:(NSString *)title
{
// Save the original title, if we haven't already.
[title retain]; // retain the title first before release lastSetTitle, since you can call setTitle on lastSetTitle itself.
[lastSetTitle release];
lastSetTitle = [title retain];
lastSetTitle = title;

// While in live resize the window title displays the dimensions of the
// window so don't clobber this with the new title. We have already set
Expand Down Expand Up @@ -934,10 +937,6 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
// Enter custom full-screen mode.
ASLogInfo(@"Enter custom full-screen");

// fullScreenWindow could be non-nil here if this is called multiple
// times during startup.
[fullScreenWindow release];

NSColor *fullscreenBg = back;

// See setDefaultColorsBackground: for why set a transparent
Expand All @@ -946,6 +945,10 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
fullscreenBg = [fullscreenBg colorWithAlphaComponent:0.001];
}

// fullScreenWindow could be non-nil here if this is called multiple
// times during startup.
[fullScreenWindow release];

fullScreenWindow = [[MMFullScreenWindow alloc]
initWithWindow:decoratedWindow view:vimView backgroundColor:fullscreenBg];
[fullScreenWindow setOptions:fuoptions];
Expand Down