Skip to content

Commit 260a214

Browse files
authored
Fix #11812 (Crash: misra addon, infinite recursion) (#5207)
1 parent 3f832df commit 260a214

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

addons/misra_9.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,13 @@ def createRecordChildrenDefs(ed, var):
476476
valueType = ed.valueType
477477
if not valueType or not valueType.typeScope:
478478
return
479-
479+
typeToken = var.typeEndToken
480+
while typeToken and typeToken.isName:
481+
typeToken = typeToken.previous
482+
if typeToken and typeToken.str == '*':
483+
child = ElementDef("pointer", var.nameToken, var.nameToken.valueType)
484+
ed.addChild(child)
485+
return
480486
for variable in valueType.typeScope.varlist:
481487
if variable is var:
482488
continue

addons/test/misra/crash3.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
3+
4+
5+
/* This is the representation of the expressions to determine the
6+
plural form. */
7+
struct expression
8+
{
9+
int nargs; /* Number of arguments. */
10+
union
11+
{
12+
unsigned long int num; /* Number value for `num'. */
13+
struct expression *args[3]; /* Up to three arguments. */
14+
} val;
15+
};
16+
17+
18+
struct expression GERMANIC_PLURAL =
19+
{
20+
.nargs = 2,
21+
.val =
22+
{
23+
.args =
24+
{
25+
[0] = (struct expression *) &plvar,
26+
[1] = (struct expression *) &plone
27+
}
28+
}
29+
};
30+

0 commit comments

Comments
 (0)