- Avoid possible seg fault when calling TRACE with NULL string pointers.
- Fix bad side-effect of makepath on input parameters.
This commit is contained in:
parent
001fa26255
commit
586808fdf2
|
@ -677,37 +677,40 @@ VOID _makepath(char * path, const char * drive,
|
||||||
const char * extension )
|
const char * extension )
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
TRACE("got %s %s %s %s\n", drive, directory,
|
char tmpPath[MAX_PATH];
|
||||||
filename, extension);
|
TRACE("got %s %s %s %s\n", debugstr_a(drive), debugstr_a(directory),
|
||||||
|
debugstr_a(filename), debugstr_a(extension) );
|
||||||
|
|
||||||
if ( !path )
|
if ( !path )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path[0] = 0;
|
tmpPath[0] = '\0';
|
||||||
if (drive && drive[0])
|
if (drive && drive[0])
|
||||||
{
|
{
|
||||||
path[0] = drive[0];
|
tmpPath[0] = drive[0];
|
||||||
path[1] = ':';
|
tmpPath[1] = ':';
|
||||||
path[2] = 0;
|
tmpPath[2] = 0;
|
||||||
}
|
}
|
||||||
if (directory && directory[0])
|
if (directory && directory[0])
|
||||||
{
|
{
|
||||||
strcat(path, directory);
|
strcat(tmpPath, directory);
|
||||||
ch = path[strlen(path)-1];
|
ch = tmpPath[strlen(tmpPath)-1];
|
||||||
if (ch != '/' && ch != '\\')
|
if (ch != '/' && ch != '\\')
|
||||||
strcat(path,"\\");
|
strcat(tmpPath,"\\");
|
||||||
}
|
}
|
||||||
if (filename && filename[0])
|
if (filename && filename[0])
|
||||||
{
|
{
|
||||||
strcat(path, filename);
|
strcat(tmpPath, filename);
|
||||||
if (extension && extension[0])
|
if (extension && extension[0])
|
||||||
{
|
{
|
||||||
if ( extension[0] != '.' )
|
if ( extension[0] != '.' )
|
||||||
strcat(path,".");
|
strcat(tmpPath,".");
|
||||||
strcat(path,extension);
|
strcat(tmpPath,extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strcpy( path, tmpPath );
|
||||||
|
|
||||||
TRACE("returning %s\n",path);
|
TRACE("returning %s\n",path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue