From 7ad360d8729d6943bf2cdf14280be019efaae57a Mon Sep 17 00:00:00 2001 From: Luflosi Date: Tue, 3 Nov 2020 16:39:18 +0100 Subject: [PATCH] Fix incorrect decrement of the reference counts of objects Found with the Clang Static Analyzer. The function `schedule_notification()` for the new notification API also does not `release` similar objects. --- kitty/cocoa_window.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index c1dd78591..fdac29c06 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -182,14 +182,9 @@ cocoa_send_notification(PyObject *self UNUSED, PyObject *args) { if (!center) {PyErr_SetString(PyExc_RuntimeError, "Failed to get the user notification center"); return NULL; } if (!center.delegate) center.delegate = [[NotificationDelegate alloc] init]; NSUserNotification *n = [NSUserNotification new]; -#define SET(x) { \ - if (x) { \ - NSString *t = @(x); \ - n.x = t; \ - [t release]; \ - }} - SET(title); SET(subtitle); SET(informativeText); -#undef SET + if (title) n.title = @(title); + if (subtitle) n.subtitle = @(subtitle); + if (informativeText) n.informativeText = @(informativeText); if (identifier) { n.userInfo = @{@"user_id": @(identifier)}; }