mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Fixed returning pointer from a local buffer
This commit is contained in:
@@ -216,13 +216,11 @@ void config_save()
|
|||||||
*/
|
*/
|
||||||
void config_init()
|
void config_init()
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
char *path = osinterface_get_orct2_homefolder();
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
||||||
|
|
||||||
strncpy(path, osinterface_get_orct2_homefolder(), MAX_PATH);
|
|
||||||
|
|
||||||
if (strcmp(path, "") != 0){
|
if (strcmp(path, "") != 0){
|
||||||
DWORD dwAttrib = GetFileAttributes(path);
|
DWORD dwAttrib = GetFileAttributes(path);
|
||||||
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
|
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
|
||||||
@@ -245,6 +243,8 @@ void config_init()
|
|||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -431,7 +431,8 @@ char* osinterface_open_directory_browser(char *title) {
|
|||||||
|
|
||||||
char* osinterface_get_orct2_homefolder()
|
char* osinterface_get_orct2_homefolder()
|
||||||
{
|
{
|
||||||
char path[260]="";
|
char *path;
|
||||||
|
path = malloc(sizeof(char) * MAX_PATH);
|
||||||
|
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
|
||||||
strcat(path, "\\OpenRCT2");
|
strcat(path, "\\OpenRCT2");
|
||||||
|
|||||||
@@ -60,17 +60,21 @@ void screenshot_check()
|
|||||||
|
|
||||||
static int screenshot_get_next_path(char *path, char *extension)
|
static int screenshot_get_next_path(char *path, char *extension)
|
||||||
{
|
{
|
||||||
|
char *homePath = osinterface_get_orct2_homefolder();
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < 1000; i++) {
|
for (i = 1; i < 1000; i++) {
|
||||||
RCT2_GLOBAL(0x013CE952, uint16) = i;
|
RCT2_GLOBAL(0x013CE952, uint16) = i;
|
||||||
|
|
||||||
// Glue together path and filename
|
// Glue together path and filename
|
||||||
sprintf(path, "%s%cSCR%d%s", osinterface_get_orct2_homefolder(), osinterface_get_path_separator(), i, extension);
|
sprintf(path, "%s%cSCR%d%s", homePath, osinterface_get_path_separator(), i, extension);
|
||||||
|
|
||||||
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
|
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(homePath);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user