ref: afadbd7aff255523ef99962dd872caad976b7b08
parent: 7ba254afe3300e88a1692ffcb72af34d025618f8
author: Ori Bernstein <[email protected]>
date: Sat Aug 29 11:34:29 EDT 2020
osx-cocoa: ensure array is non-empty before indexing If we have nothing pastable, we can get either a nil or an empty array. We were checking for nil, but we'd index the empty array and crash. Now we don't.
--- a/gui-cocoa/screen.m
+++ b/gui-cocoa/screen.m
@@ -74,7 +74,7 @@
NSArray *classes = [NSArray arrayWithObjects:[NSString class], nil];
NSDictionary *options = [NSDictionary dictionary];
NSArray *it = [pb readObjectsForClasses:classes options:options];
- if(it != nil)
+ if(it != nil && [it count] > 0)
return strdup([it[0] UTF8String]);
return nil;
}