aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc/variable.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-10-17 15:28:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2024-10-17 15:28:32 -0400
commit1fed234f9faf1071d925434c5e9c14688fb4c77e (patch)
treee682cc737b24251fd37c7ac366317eaa365accf6 /src/interfaces/ecpg/preproc/variable.c
parent98c7c7152d2d4670a349c0fe48f05cf95c0b1185 (diff)
downloadpostgresql-1fed234f9faf1071d925434c5e9c14688fb4c77e.tar.gz
postgresql-1fed234f9faf1071d925434c5e9c14688fb4c77e.zip
ecpg: fix more minor mishandling of bad input in preprocessor.
Don't get confused by an unmatched right brace in the input. (Previously, this led to discarding information about file-level variables and then possibly crashing.) Detect, rather than crash on, an attempt to index into a non-array variable. As before, in the absence of field complaints I'm not too excited about back-patching these. Per valgrind testing by Alexander Lakhin. Discussion: https://postgr.es/m/a239aec2-6c79-5fc9-9272-cea41158a360@gmail.com
Diffstat (limited to 'src/interfaces/ecpg/preproc/variable.c')
-rw-r--r--src/interfaces/ecpg/preproc/variable.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index a4294b8f0ff..ac80d2c0209 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -233,7 +233,8 @@ find_variable(const char *name)
p = find_simple(name);
if (p == NULL)
mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
-
+ if (p->type->type != ECPGt_array)
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer", name);
*next = c;
switch (p->type->u.element->type)
{