Re: arrayfuncs: fix read of uninitialized mem - Mailing list pgsql-patches

From Tom Lane
Subject Re: arrayfuncs: fix read of uninitialized mem
Date
Msg-id 3328.1095257892@sss.pgh.pa.us
Whole thread Raw
In response to arrayfuncs: fix read of uninitialized mem  (Neil Conway <neilc@samurai.com>)
Responses Re: arrayfuncs: fix read of uninitialized mem
List pgsql-patches
Neil Conway <neilc@samurai.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

pgsql-patches by date:

Previous
From: Mahmoud Taghizadeh
Date:
Subject: Again!! locale per column for postgreSQL
Next
From: Karel Zak
Date:
Subject: Re: Again!! locale per column for postgreSQL