mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fixed returning pointer from a local buffer
This commit is contained in:
parent
07128831fb
commit
35ff9a510d
|
@ -216,13 +216,11 @@ void config_save()
|
|||
*/
|
||||
void config_init()
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
char *path = osinterface_get_orct2_homefolder();
|
||||
FILE* fp;
|
||||
|
||||
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
||||
|
||||
strncpy(path, osinterface_get_orct2_homefolder(), MAX_PATH);
|
||||
|
||||
if (strcmp(path, "") != 0){
|
||||
DWORD dwAttrib = GetFileAttributes(path);
|
||||
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
|
||||
|
@ -245,6 +243,8 @@ void config_init()
|
|||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
free(path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -431,7 +431,8 @@ char* osinterface_open_directory_browser(char *title) {
|
|||
|
||||
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
|
||||
strcat(path, "\\OpenRCT2");
|
||||
|
|
|
@ -60,17 +60,21 @@ void screenshot_check()
|
|||
|
||||
static int screenshot_get_next_path(char *path, char *extension)
|
||||
{
|
||||
char *homePath = osinterface_get_orct2_homefolder();
|
||||
|
||||
int i;
|
||||
for (i = 1; i < 1000; i++) {
|
||||
RCT2_GLOBAL(0x013CE952, uint16) = i;
|
||||
|
||||
// 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)
|
||||
return i;
|
||||
}
|
||||
|
||||
free(homePath);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue