From 16c0bde2f43811bde4aa33ed392433e66fa48b9c Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Mon, 26 May 2014 09:34:14 +0200 Subject: [PATCH] Check if path could be allocated, initialize it with an empty string. --- src/osinterface.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osinterface.c b/src/osinterface.c index 5a17fae968..fdc237d4ad 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -431,8 +431,14 @@ char* osinterface_open_directory_browser(char *title) { char* osinterface_get_orct2_homefolder() { - char *path; + char *path=NULL; path = malloc(sizeof(char) * MAX_PATH); + if (path == NULL){ + osinterface_show_messagebox("Error allocating memory!"); + exit(EXIT_FAILURE); + } + + path[0] = '\0'; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder strcat(path, "\\OpenRCT2");