aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-04-04 21:28:43 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-04-04 21:36:34 +0200
commit2cd6d34e815a7442b0b113f395504131b3a92e77 (patch)
tree9f6191c9d40be12fab6a32d7b892e82e9859108e /validation
parent6d5d9b420b2f0e86a01dc40524f31bd80f5ec3ee (diff)
downloadsparse-dev-2cd6d34e815a7442b0b113f395504131b3a92e77.tar.gz
fix null-pointer crash with with ident same as one of the attributes
match_attribute() will crash when the token has the same identifier as one of the attributes but is not an attribute. In this case, the corresponding symbol_op will be null but this is not checked. This seems to happen only with old-style declarations. Fix this by adding the missing null-check. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/knr-attr-crash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/validation/knr-attr-crash.c b/validation/knr-attr-crash.c
new file mode 100644
index 00000000..176ff503
--- /dev/null
+++ b/validation/knr-attr-crash.c
@@ -0,0 +1,12 @@
+typedef int word;
+
+void foo(word x);
+
+void foo(x)
+ word x;
+{ }
+
+/*
+ * check-name: knr-attr-crash
+ * check-command: sparse -Wno-old-style-definition $file
+ */