mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +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:
parent
d13ac450d8
commit
acb3b443f7
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue