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

Re: arrayfuncs: fix read of uninitialized mem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: arrayfuncs: fix read of uninitialized mem
Date: 2004-09-15 14:18:12
Message-ID: 3328.1095257892@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Neil Conway <neilc(at)samurai(dot)com> writes:
> I fixed it by initializing dims_str[0] to '\0' circa line 1018 in
> current sources. While doing so I couldn't resist the temptation to fix
> a few of arrayfunc.c's crimes against good programming practise, so the
> attached patch includes some additional cosmetic improvements.

I dislike what you did at lines 983-1012 (replace a local variable by
possibly-many stores into an array).  Also, as long as we're fixing
unreadable code, how about (line 1019)

	for (i = j = 0, k = 1; i < ndim; k *= dims[i++], j += k);

becomes

 	for (i = j = 0, k = 1; i < ndim; i++)
		k *= dims[i], j += k;

or some such.  The empty loop body is a mistake waiting to happen.

Looks fine to me otherwise.

			regards, tom lane

In response to

Responses

pgsql-patches by date

Next:From: Karel ZakDate: 2004-09-15 14:21:02
Subject: Re: Again!! locale per column for postgreSQL
Previous:From: Mahmoud TaghizadehDate: 2004-09-15 14:01:35
Subject: Again!! locale per column for postgreSQL

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