mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
(trunk libT) silently add a \0 after the end of files read by tr_loadFile() so that text files can be handled directly as ascii strings
This commit is contained in:
@@ -497,7 +497,7 @@ tr_loadFile( const char * path,
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
buf = malloc( sb.st_size );
|
||||
buf = malloc( sb.st_size + 1 );
|
||||
if( !buf )
|
||||
{
|
||||
const int err = errno;
|
||||
@@ -517,6 +517,7 @@ tr_loadFile( const char * path,
|
||||
}
|
||||
|
||||
tr_close_file( fd );
|
||||
buf[ sb.st_size ] = '\0';
|
||||
*size = sb.st_size;
|
||||
return buf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user