gccrs: Fix nullptr dereference
authorPhilip Herron <herron.philip@googlemail.com>
Tue, 31 Jan 2023 14:27:49 +0000 (14:27 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 6 Apr 2023 08:47:21 +0000 (10:47 +0200)
When we check if this is concrete the guard checks to ensure the argument
is non null but the check here is wrongly returning early when the check
is non null meaning when it is null and therefore not concrete it will
end up doing a null dereference.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.cc (SubstitutionArg::is_conrete): fix check

gcc/rust/typecheck/rust-tyty-subst.cc

index 7f5bb22..996bbf2 100644 (file)
@@ -213,8 +213,8 @@ SubstitutionArg::is_error () const
 bool
 SubstitutionArg::is_conrete () const
 {
-  if (argument != nullptr)
-    return true;
+  if (argument == nullptr)
+    return false;
 
   if (argument->get_kind () == TyTy::TypeKind::PARAM)
     return false;