Skip to content

Commit b22abbc

Browse files
authored
fix crash (#44)
1 parent 6516778 commit b22abbc

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/macos.mm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ bool _requestAccessibility(bool showDialog) {
3030
NSNumber *windowNumber = info[(id)kCGWindowNumber];
3131

3232
if ([windowNumber intValue] == handle) {
33-
CFRelease(windowList);
34-
return info;
33+
NSDictionary* windowInfo = (NSDictionary*)CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (CFPropertyListRef)info, kCFPropertyListMutableContainers);
34+
CFRelease(windowList);
35+
return windowInfo;
3536
}
3637
}
3738

@@ -136,11 +137,9 @@ AXUIElementRef getAXWindowById(int handle) {
136137
auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue]];
137138

138139
if (![app isActive]) {
139-
[app release];
140140
continue;
141141
}
142142

143-
[app release];
144143
CFRelease(windowList);
145144
return Napi::Number::New(env, [windowNumber intValue]);
146145
}
@@ -166,7 +165,6 @@ AXUIElementRef getAXWindowById(int handle) {
166165

167166
cacheWindow(handle, [ownerPid intValue]);
168167

169-
[app release];
170168
return obj;
171169
}
172170

0 commit comments

Comments
 (0)