From 40517565761a46a3417ed031f54fe4d0c75cc8c3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 20 Jul 2014 10:15:49 -0700 Subject: [PATCH] Check for null map in matchtag(). --- sourcepawn/compiler/sc3.c | 2 +- sourcepawn/compiler/tests/fail-assign-null-to-any.sp | 4 ++++ sourcepawn/compiler/tests/fail-assign-null-to-any.txt | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 sourcepawn/compiler/tests/fail-assign-null-to-any.sp create mode 100644 sourcepawn/compiler/tests/fail-assign-null-to-any.txt diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 4e6e31f9..e0844c66 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -384,7 +384,7 @@ static int matchobjecttags(int formaltag, int actualtag, int flags) // Some methodmaps are nullable. The nullable property is inherited // automatically. methodmap_t *map = methodmap_find_by_tag(formaltag); - if (map->nullable) + if (map && map->nullable) return TRUE; error(148, pc_tagname(formaltag)); diff --git a/sourcepawn/compiler/tests/fail-assign-null-to-any.sp b/sourcepawn/compiler/tests/fail-assign-null-to-any.sp new file mode 100644 index 00000000..16be5876 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-assign-null-to-any.sp @@ -0,0 +1,4 @@ +Foo(any foo) {} +public Bar() { + Foo(null); +} diff --git a/sourcepawn/compiler/tests/fail-assign-null-to-any.txt b/sourcepawn/compiler/tests/fail-assign-null-to-any.txt new file mode 100644 index 00000000..cb98bb52 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-assign-null-to-any.txt @@ -0,0 +1 @@ +(3) : error 148: cannot assign null to a non-nullable type