mirror of
https://github.com/transmission/transmission.git
synced 2025-12-25 04:45:56 +00:00
(trunk) improvement to r11864
Since the contents of getcwd() are undefined on error, explicitly terminate the buffer string if getcwd() fails.
This commit is contained in:
@@ -80,14 +80,16 @@ tr_getcwd( void )
|
||||
{
|
||||
char * result;
|
||||
char buf[2048];
|
||||
*buf = '\0';
|
||||
#ifdef WIN32
|
||||
result = _getcwd( buf, sizeof( buf ) );
|
||||
#else
|
||||
result = getcwd( buf, sizeof( buf ) );
|
||||
#endif
|
||||
if( result == NULL )
|
||||
if( result == NULL )
|
||||
{
|
||||
fprintf( stderr, "getcwd error: \"%s\"", tr_strerror( errno ) );
|
||||
*buf = '\0';
|
||||
}
|
||||
return tr_strdup( buf );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user