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:
parent
fbc84c2aad
commit
7bd8874cf3
19
src/misc.cpp
19
src/misc.cpp
@ -101,22 +101,21 @@ void AddUserPath(char *pFilename)
|
|||||||
char last;
|
char last;
|
||||||
|
|
||||||
temp = SDL_GetPrefPath ("Epsitec SA", "Planet Blupi");
|
temp = SDL_GetPrefPath ("Epsitec SA", "Planet Blupi");
|
||||||
|
std::string path = temp;
|
||||||
|
|
||||||
pText = strstr(pFilename, "/");
|
pText = strstr(pFilename, "/");
|
||||||
if ( pText != nullptr )
|
if ( pText != nullptr )
|
||||||
{
|
{
|
||||||
pos = strlen(temp)+(pText-pFilename)+1;
|
pos = path.size () + (pText - pFilename) + 1;
|
||||||
strcat(temp, pFilename);
|
path += pFilename;
|
||||||
last = temp[pos];
|
last = path[pos];
|
||||||
temp[pos] = 0;
|
path[pos] = 0;
|
||||||
mkdir (temp, 755);
|
mkdir (path.c_str (), 755);
|
||||||
temp[pos] = last;
|
path[pos] = last;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
path += pFilename;
|
||||||
strcat(temp, pFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(pFilename, temp);
|
strcpy(pFilename, path.c_str ());
|
||||||
SDL_free (temp);
|
SDL_free (temp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user