Avoids a file descriptor leak seen with initWithContentsOfFile since macOS 10.15 (Catalina).
struct stat stb;
if (stat(path, &stb) == 0) {
/* Load the sound into memory */
- sound = [[NSSound alloc]
- initWithContentsOfFile:[NSString stringWithUTF8String:path]
- byReference:YES];
+ NSData *fileData = [NSData dataWithContentsOfFile:[NSString stringWithUTF8String:path]];
+ sound = [[NSSound alloc] initWithData:fileData];
if (sound) {
[self->soundsByPath setObject:sound
forKey:token_string];