cppcheckdata: Fix crash on an empty union (#3326)

This commit is contained in:
Georgiy Komarov 2021-07-06 18:01:58 +03:00 committed by GitHub
parent 7d7241b076
commit 6f389014f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -404,7 +404,9 @@ class Scope:
self.nestedIn = IdMap[self.nestedInId]
self.function = IdMap[self.functionId]
for v in self.varlistId:
self.varlist.append(IdMap[v])
value = IdMap.get(v)
if value:
self.varlist.append(value)
class Function:

View File

@ -41,6 +41,16 @@
#include <tgmath.h> // 21.11
#include <fenv.h>
// Check that the addon doesn't crash
typedef struct {
union { // 19.2
struct {
unsigned a : 2;
unsigned : 14;
};
uint16_t value;
};
} STRUCT_BITS;
typedef unsigned char u8;
typedef unsigned short u16;