1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +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:
Charles Kerr 2009-04-28 20:42:55 +00:00
parent d13ac450d8
commit acb3b443f7

View file

@ -497,7 +497,7 @@ tr_loadFile( const char * path,
errno = err; errno = err;
return NULL; return NULL;
} }
buf = malloc( sb.st_size ); buf = malloc( sb.st_size + 1 );
if( !buf ) if( !buf )
{ {
const int err = errno; const int err = errno;
@ -517,6 +517,7 @@ tr_loadFile( const char * path,
} }
tr_close_file( fd ); tr_close_file( fd );
buf[ sb.st_size ] = '\0';
*size = sb.st_size; *size = sb.st_size;
return buf; return buf;
} }