From 3c237e7347ff25735b6dbb7f9f6a8cf3d77f8608 Mon Sep 17 00:00:00 2001
From: "Marc G. Fournier" <scrappy@hub.org>
Date: Thu, 19 Sep 1996 20:05:59 +0000
Subject: [PATCH] I have two small patches which correct some very obscure bug
 in the parser of the array constants and in one of the loadable modules I
 posted some time ago.

Submitted by: Massimo Dal Zotto <dz@cs.unitn.it>
---
 contrib/string/string_io.c         | 2 +-
 src/backend/utils/adt/arrayfuncs.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c
index ab49c5321a3..b6158c74e43 100644
--- a/contrib/string/string_io.c
+++ b/contrib/string/string_io.c
@@ -79,7 +79,7 @@ string_output(char *data, int size)
 	    len++;
 	    break;
 	  default:
-	    if (NOTPRINTABLE(c)) {
+	    if (NOTPRINTABLE(*p)) {
 		len += 3;
 	    }
 	}
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index acaeeb067c8..f3a7d5c3809 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.4 1996/08/27 07:32:27 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.5 1996/09/19 20:04:56 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -235,6 +235,10 @@ _ArrayCount(char *str, int dim[], int typdelim)
                 }
                 break;
 #endif
+	    case '\0':
+		/* Signal a premature end of the string.  DZ - 2-9-1996 */
+		elog(WARN, "malformed array constant: %s", str);
+		break;
 	    case '\"':
 		scanning_string = ! scanning_string;
 		break;
-- 
GitLab