Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1fed234

Browse files
committed
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-levelvariables and then possibly crashing.)Detect, rather than crash on, an attempt to index into a non-arrayvariable.As before, in the absence of field complaints I'm not tooexcited about back-patching these.Per valgrind testing by Alexander Lakhin.Discussion:https://postgr.es/m/a239aec2-6c79-5fc9-9272-cea41158a360@gmail.com
1 parent98c7c71 commit1fed234

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ statement: ecpgstart at toplevel_stmt ';'
4343
}
4444
| '}'
4545
{
46-
remove_typedefs(braces_open);
47-
remove_variables(braces_open--);
48-
if (braces_open == 0)
46+
if (braces_open > 0)
4947
{
50-
free(current_function);
51-
current_function = NULL;
48+
remove_typedefs(braces_open);
49+
remove_variables(braces_open);
50+
if (--braces_open == 0)
51+
{
52+
free(current_function);
53+
current_function = NULL;
54+
}
5255
}
5356
fputs("}", base_yyout);
5457
}

‎src/interfaces/ecpg/preproc/variable.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ find_variable(const char *name)
233233
p=find_simple(name);
234234
if (p==NULL)
235235
mmfatal(PARSE_ERROR,"variable \"%s\" is not declared",name);
236-
236+
if (p->type->type!=ECPGt_array)
237+
mmfatal(PARSE_ERROR,"variable \"%s\" is not a pointer",name);
237238
*next=c;
238239
switch (p->type->u.element->type)
239240
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp