Tweak ArrayCount() to forestall possible access to temp[-1]. Problem
authorTom Lane
Wed, 29 Jan 2003 01:28:33 +0000 (01:28 +0000)
committerTom Lane
Wed, 29 Jan 2003 01:28:33 +0000 (01:28 +0000)
cannot actually happen at present because ArrayCount() is only called
on strings beginning with '{', but seems best to prevent it going forward.
Per report from Yichen Xie.

src/backend/utils/adt/arrayfuncs.c

index c791877bb5b70670be308a53c97b250cf84963c5..dc6ace3ed6cdf129c8aba1bb0a86a4e86c69a2b4 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.85 2002/11/13 00:39:47 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.86 2003/01/29 01:28:33 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -275,7 +275,7 @@ ArrayCount(char *str, int *dim, char typdelim)
 {
    int         nest_level = 0,
                i;
-   int         ndim = 0,
+   int         ndim = 1,
                temp[MAXDIM];
    bool        scanning_string = false;
    bool        eoArray = false;