fix minor memory error in initdb - Mailing list pgsql-patches

From Neil Conway
Subject fix minor memory error in initdb
Date
Msg-id 87isir3h4e.fsf@mailbox.samurai.com
Whole thread Raw
List 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

pgsql-patches by date:

Previous
From: "Wiseguy"
Date:
Subject: unified diffs, PLEASE?
Next
From: Tatsuo Ishii
Date:
Subject: Re: [HACKERS] v7.4.1 text_position() patch