Skip site navigation (1) Skip section navigation (2)

fix minor memory error in initdb

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: fix minor memory error in initdb
Date: 2004-01-31 22:09:21
Message-ID: 87isir3h4e.fsf@mailbox.samurai.com (view raw or flat)
Thread:
Lists: pgsql-patches
The new C version of initdb presently provokes the following valgrind
warnings:

==15366== 
==15366== Conditional jump or move depends on uninitialised value(s)
==15366==    at 0x8049713: mkdir_p (initdb.c:556)
==15366==    by 0x8049C8E: mkdatadir (initdb.c:812)
==15366==    by 0x804C833: main (initdb.c:2370)
==15366== Invalid read of size 1
==15366==    at 0x8049710: mkdir_p (initdb.c:556)
==15366==    by 0x8049C8E: mkdatadir (initdb.c:812)
==15366==    by 0x804C957: main (initdb.c:2418)
==15366==  Address 0x4177D8D3 is 0 bytes after a block of size 19 alloc'd
==15366==    at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==15366==    by 0x8049084: xmalloc (initdb.c:249)
==15366==    by 0x8049C39: mkdatadir (initdb.c:804)
==15366==    by 0x804C957: main (initdb.c:2418)

I doubt the mistake that causes these warnings would cause any
problems in practise (mkdir_p() reads one past the end of the string
passed into it, but doesn't actually change any meaningful state based
on what it reads), but being valgrind-clean is a good thing, so I've
applied the attached one-line patch to fix this.

-Neil


Attachment: initdb-mem-read-fix-1.patch
Description: text/x-patch (612 bytes)

pgsql-patches by date

Next:From: Tatsuo IshiiDate: 2004-02-01 00:34:51
Subject: Re: [PATCHES] v7.4.1 text_position() patch
Previous:From: WiseguyDate: 2004-01-31 19:10:11
Subject: unified diffs, PLEASE?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group