From 8c3f36f890009c8a9b1809107c3bdf8120d998a5 Mon Sep 17 00:00:00 2001 From: boercher Date: Fri, 19 Aug 2005 23:13:05 +0000 Subject: [PATCH] fixed valgrind-warnings: - added missing initialization of buffile->buf - corrected malloc-call --- shared/fileio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/fileio.c b/shared/fileio.c index 6b3ba70..c66114d 100644 --- a/shared/fileio.c +++ b/shared/fileio.c @@ -27,6 +27,7 @@ buffile *buffile_open( const char *path, const char *mode ) { file->pos=0; file->bytesread=0; + file->buf=NULL; file->f = fopen( path, mode ); if( NULL == file->f ) { @@ -76,7 +77,7 @@ char * buffile_read ( buffile * file, size_t n ) { } file->pos = 0; } - strncpy(returnbuf, file->buf + (file->pos++), sizeof(returnbuf)); + strncpy(returnbuf, file->buf + (file->pos++), n); return returnbuf; }