From acb3b443f703704f4c59618a4cf74776e474c7c4 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 28 Apr 2009 20:42:55 +0000 Subject: [PATCH] (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 --- libtransmission/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.40.0