From 5a49b70ba43a72285b946ea9ac4dd2d8d8ee5d77 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Tue, 20 Oct 2015 20:25:15 +0200 Subject: [PATCH] Fixed an issue where the memory leak log name was null on Windows. --- src/common/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/core.c b/src/common/core.c index 52c2f147d0..675678ea4c 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -259,7 +259,7 @@ const char *get_git_hash (void) { if( (fp = fopen(".git/"GIT_ORIGIN, "r")) != NULL ) { char line[64]; - char *rev = malloc(sizeof(char) * 50); + char *rev = (char*)malloc(sizeof(char) * 50); if( fgets(line, sizeof(line), fp) && sscanf(line, "%40s", rev) ) snprintf(GitHash, sizeof(GitHash), "%s", rev); @@ -325,10 +325,13 @@ int main (int argc, char **argv) int n=0; SERVER_NAME = ++p1; n = p1-argv[0]; //calc dir name len - pwd = safestrncpy(malloc(n + 1), argv[0], n); + pwd = safestrncpy((char*)malloc(n + 1), argv[0], n); if(chdir(pwd) != 0) ShowError("Couldn't change working directory to %s for %s, runtime will probably fail",pwd,SERVER_NAME); free(pwd); + }else{ + // On Windows the .bat files have the executeable names as parameters without any path seperator [Lemongrass] + SERVER_NAME = argv[0]; } }