Skip to content

Commit 2e27df3

Browse files
committed
Prevented minor memory leak in STPrivilegedTask, silenced static analyzer complaints
1 parent 3e16f49 commit 2e27df3

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

Application/EditorController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ - (instancetype)init {
5454

5555
- (void)awakeFromNib {
5656
NSNumber *userFontSizeNum = [DEFAULTS objectForKey:DefaultsKey_EditorFontSize];
57-
CGFloat fontSize = userFontSizeNum ? [userFontSizeNum floatValue] : DEFAULT_TEXT_FONT_SIZE;
57+
CGFloat fontSize = userFontSizeNum != nil ? [userFontSizeNum floatValue] : DEFAULT_TEXT_FONT_SIZE;
5858
NSFont *font = [NSFont fontWithName:DEFAULT_TEXT_FONT_NAME size:fontSize];
5959
[textView setFont:font];
6060
[textView setAutomaticQuoteSubstitutionEnabled:NO];

Application/Resources/Platypus-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
<key>CFBundleSignature</key>
446446
<string>????</string>
447447
<key>CFBundleVersion</key>
448-
<string>1331</string>
448+
<string>1332</string>
449449
<key>LSApplicationCategoryType</key>
450450
<string>public.app-category.developer-tools</string>
451451
<key>LSMinimumSystemVersion</key>

ScriptExec/SEController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ - (void)loadAppSettings {
284284

285285
// Font and size
286286
NSNumber *userFontSizeNum = [DEFAULTS objectForKey:ScriptExecDefaultsKey_UserFontSize];
287-
CGFloat fontSize = userFontSizeNum ? [userFontSizeNum floatValue] : [appSettings[AppSpecKey_TextSize] floatValue];
287+
CGFloat fontSize = userFontSizeNum != nil ? [userFontSizeNum floatValue] : [appSettings[AppSpecKey_TextSize] floatValue];
288288
fontSize = fontSize != 0 ? fontSize : DEFAULT_TEXT_FONT_SIZE;
289289

290290
if (appSettings[AppSpecKey_TextFont]) {
291291
textFont = [NSFont fontWithName:appSettings[AppSpecKey_TextFont] size:fontSize];
292292
}
293293
if (textFont == nil) {
294-
textFont = [NSFont fontWithName:DEFAULT_TEXT_FONT_NAME size:DEFAULT_TEXT_FONT_SIZE];
294+
textFont = [NSFont fontWithName:DEFAULT_TEXT_FONT_NAME size:fontSize];
295295
}
296296

297297
BOOL darkMode = NO;

Shared/STPrivilegedTask.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import <stdio.h>
3232
#import <unistd.h>
3333
#import <dlfcn.h>
34+
#import <sys/param.h>
3435

3536
// New error code denoting that AuthorizationExecuteWithPrivileges no longer exists
3637
OSStatus const errAuthorizationFnNoLongerExists = -70001;
@@ -217,7 +218,8 @@ - (OSStatus)launchWithAuthorization:(AuthorizationRef)authorization
217218
args[numberOfArguments] = NULL;
218219

219220
// change to the current dir specified
220-
char *prevCwd = (char *)getcwd(nil, 0);
221+
char prevCwd[MAXPATHLEN];
222+
getcwd(prevCwd, sizeof(prevCwd));
221223
chdir([self.currentDirectoryPath fileSystemRepresentation]);
222224

223225
//use Authorization Reference to execute script with privileges

0 commit comments

Comments
 (0)