diff --git a/libtransmission/utils.c b/libtransmission/utils.c index c57b44738..ac11d5c8a 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -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; }