1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-05 04:30:38 +03:00

simplify os2FullPathname() and at the same time make the allocations more robust (CVS 4647)

FossilOrigin-Name: 6f8952a8366065c9baa48cacc9c36743788210db
This commit is contained in:
pweilbacher
2007-12-30 23:35:15 +00:00
parent efd9eff475
commit ce3dc640f5
3 changed files with 10 additions and 12 deletions

View File

@@ -790,21 +790,19 @@ static int os2FullPathname(
char *zFull /* Output buffer */
){
if( strchr(zRelative, ':') ){
sqlite3SetString( &zFull, zRelative, (char*)0 );
sqlite3_snprintf( nFull, zFull, "%s", zRelative );
}else{
ULONG ulDriveNum = 0;
ULONG ulDriveMap = 0;
ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE;
char zDrive[2];
char *zBuff = (char*)malloc( cbzBufLen );
if( zBuff == 0 ){
return SQLITE_NOMEM;
}
DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
if( DosQueryCurrentDir( ulDriveNum, (PBYTE)zBuff, &cbzBufLen ) == NO_ERROR ){
sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) );
sqlite3SetString( &zFull, zDrive, ":\\", zBuff,
"\\", zRelative, (char*)0 );
sqlite3_snprintf( nFull, zFull, "%c:\\%s\\%s",
(char)('A' + ulDriveNum - 1), zBuff, zRelative);
}
free( zBuff );
}