1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Fix memory overflow

This commit is contained in:
Mathieu Schroeter 2017-02-11 23:19:47 +01:00
parent fbc84c2aad
commit 7bd8874cf3

View File

@ -101,22 +101,21 @@ void AddUserPath(char *pFilename)
char last;
temp = SDL_GetPrefPath ("Epsitec SA", "Planet Blupi");
std::string path = temp;
pText = strstr(pFilename, "/");
if ( pText != nullptr )
{
pos = strlen(temp)+(pText-pFilename)+1;
strcat(temp, pFilename);
last = temp[pos];
temp[pos] = 0;
mkdir (temp, 755);
temp[pos] = last;
pos = path.size () + (pText - pFilename) + 1;
path += pFilename;
last = path[pos];
path[pos] = 0;
mkdir (path.c_str (), 755);
path[pos] = last;
}
else
{
strcat(temp, pFilename);
}
path += pFilename;
strcpy(pFilename, temp);
strcpy(pFilename, path.c_str ());
SDL_free (temp);
}