changeset 2943:fbf43ea71c8e

Mac: Fix a double free error caused by the dw_debug() changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 Jan 2023 01:32:18 +0000
parents 63d7baebb0d4
children 3dde7456c9f6
files mac/dw.m
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Sun Jan 01 06:21:00 2023 +0000
+++ b/mac/dw.m	Mon Jan 02 01:32:18 2023 +0000
@@ -4349,18 +4349,20 @@
  */
 void API dw_debug(const char *format, ...)
 {
-   va_list args;
-
-   va_start(args, format);
-   dw_vdebug(format, args);
-   va_end(args);
+    va_list args;
+
+    va_start(args, format);
+    dw_vdebug(format, args);
+    va_end(args);
 }
 
 void API dw_vdebug(const char *format, va_list args)
 {
-   NSString *nformat = [[NSString stringWithUTF8String:format] autorelease];
-
-   NSLogv(nformat, args);
+    DW_LOCAL_POOL_IN;
+    NSString *nformat = [NSString stringWithUTF8String:format];
+
+    NSLogv(nformat, args);
+    DW_LOCAL_POOL_OUT;
 }
 
 /*
@@ -4384,6 +4386,7 @@
 
 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args)
 {
+    DW_LOCAL_POOL_IN;
     NSInteger iResponse;
     NSString *button1 = @"OK";
     NSString *button2 = nil;
@@ -4437,6 +4440,7 @@
         case NSAlertThirdButtonReturn:      /* user pressed the third button */
             return DW_MB_RETURN_CANCEL;
     }
+    DW_LOCAL_POOL_OUT;
     return 0;
 }