Skip to content

Commit

Permalink
Fix #11812 (Crash: misra addon, infinite recursion) (#5207)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jul 4, 2023
1 parent 3f832df commit 260a214
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addons/misra_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ def createRecordChildrenDefs(ed, var):
valueType = ed.valueType
if not valueType or not valueType.typeScope:
return

typeToken = var.typeEndToken
while typeToken and typeToken.isName:
typeToken = typeToken.previous
if typeToken and typeToken.str == '*':
child = ElementDef("pointer", var.nameToken, var.nameToken.valueType)
ed.addChild(child)
return
for variable in valueType.typeScope.varlist:
if variable is var:
continue
Expand Down
30 changes: 30 additions & 0 deletions addons/test/misra/crash3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@




/* This is the representation of the expressions to determine the
plural form. */
struct expression
{
int nargs; /* Number of arguments. */
union
{
unsigned long int num; /* Number value for `num'. */
struct expression *args[3]; /* Up to three arguments. */
} val;
};


struct expression GERMANIC_PLURAL =
{
.nargs = 2,
.val =
{
.args =
{
[0] = (struct expression *) &plvar,
[1] = (struct expression *) &plone
}
}
};

0 comments on commit 260a214

Please sign in to comment.