1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fully initialize the unused bytes of the buffer that will become the journal

file header, in order to silence a complaint from valgrind. (CVS 5968)

FossilOrigin-Name: 2822cbb960dbef9d30586ee112d74f9f566309fa
This commit is contained in:
drh
2008-11-29 22:49:23 +00:00
parent 9b35ea62c7
commit 08609ce7f0
3 changed files with 17 additions and 8 deletions

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.509 2008/11/26 07:25:52 danielk1977 Exp $
** @(#) $Id: pager.c,v 1.510 2008/11/29 22:49:23 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -681,6 +681,15 @@ static int writeJournalHdr(Pager *pPager){
put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbSize);
/* The assumed sector size for this process */
put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);
/* Initializing the tail of the buffer is not necessary. Everything
** works find if the following memset() is omitted. But initializing
** the memory prevents valgrind from complaining, so we are willing to
** take the performance hit.
*/
memset(&zHeader[sizeof(aJournalMagic)+16], 0,
nHeader-(sizeof(aJournalMagic)+16));
if( pPager->journalHdr==0 ){
/* The page size */
put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);