From 553e16144bced87ea5f085169ed73ec0cb9349c6 Mon Sep 17 00:00:00 2001 From: Sjors Gielen Date: Fri, 14 Jul 2017 01:12:03 +0200 Subject: [PATCH] Fix null pointer dereference when cancelling an RCT1 location dialog on Mac OS X. To reproduce, run openrct2 on OSX, go to the options dialog, then to the bottom of the misc tab, select an RCT1 location. Then, cancel that dialog. This would trigger a null pointer dereference by returning std::string(nullptr). --- src/openrct2-ui/UiContext.macOS.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2-ui/UiContext.macOS.mm b/src/openrct2-ui/UiContext.macOS.mm index a78ea82395..1de0b0684f 100644 --- a/src/openrct2-ui/UiContext.macOS.mm +++ b/src/openrct2-ui/UiContext.macOS.mm @@ -118,14 +118,14 @@ namespace OpenRCT2 { namespace Ui panel.canChooseFiles = false; panel.canChooseDirectories = true; panel.allowsMultipleSelection = false; - utf8 *url = NULL; if ([panel runModal] == NSFileHandlingPanelOKButton) { NSString *selectedPath = panel.URL.path; const char *path = selectedPath.UTF8String; - url = _strdup(path); + return path; + } else { + return ""; } - return url; } }