Skip to content

Commit acc76ba

Browse files
committed
VHDL: avoid dereferencing NULL as a tagEntryInfo
Close #3158. In the process of finding the end of a package, the parser accessed the internal of the tag entry for the package for filling end: filed of the tag. In the case the tag of the package was not created, the accessing caused a crash. This change limits the access. This change doesn't consider the reason why the tag for the package is not created. Following code snippets taken from the real code are triggering the crashes: -- psi_fix/model/snippets/psi_fix_pkg_writer_tmpl.vhd -- in https://github.com/paulscherrerinstitute/psi_fix -- reported in #3158 by @tsenart package body <PACKAGE_NAME> is ... end <PACKAGE_NAME>; -- ghdl/testsuite/vests/vhdl-ams/ashenden/compliant/access-types/ordered_collection_adt.vhd -- in https://github.com/peteut/ghdl -- reported in #3158 by @tsenart package «element_type_simple_name»_ordered_collection_adt is ... Signed-off-by: Masatake YAMATO <[email protected]>
1 parent b5bda24 commit acc76ba

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This includes input files that crashed ctags processes.
2+
The validity of the input files is not considered well.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package body

parsers/vhdl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,18 @@ static void parseTillEnd (tokenInfo * const token, int parent, const int end_key
589589
{
590590
bool ended = false;
591591
tagEntryInfo *e = getEntryInCorkQueue (parent);
592-
const char *end_id = e->name;
592+
/* If e is NULL, the input may be broken as VHDL code
593+
* or unsupported syntax in this parser. */
593594

594595
do
595596
{
596597
readToken (token);
597598
if (isKeyword (token, KEYWORD_END))
598599
{
599600
readToken (token);
600-
ended = isSemicolonOrKeywordOrIdent (token,
601-
end_keyword, end_id);
601+
if (e)
602+
ended = isSemicolonOrKeywordOrIdent (token,
603+
end_keyword, e->name);
602604
if (!isType (token, TOKEN_SEMICOLON))
603605
skipToCharacterInInputFile (';');
604606
if (ended)

0 commit comments

Comments
 (0)