Put index check before use.
authorMartin Liska <mliska@suse.cz>
Tue, 4 Feb 2020 13:57:59 +0000 (14:57 +0100)
committerMartin Liska <mliska@suse.cz>
Tue, 5 May 2020 13:54:57 +0000 (15:54 +0200)
liboffloadmic/ChangeLog:

2020-02-04  Martin Liska  <mliska@suse.cz>

PR other/89860
* runtime/offload_target.cpp: Put index check
before its use.

liboffloadmic/runtime/offload_target.cpp

index 8273faac13b852d50a27eb2c4075e657601086d0..16ba4a329911f438ce06e879fd5f1e2f88732b3a 100644 (file)
@@ -329,7 +329,7 @@ void OffloadDescriptor::merge_var_descs(
                 }
             }
             // instead of m_vars[i].type.dst we will use m_vars_extra[i].type_dst
-            if (m_vars[i].type.dst == c_extended_type && i < vars_total) {
+            if (i < vars_total && m_vars[i].type.dst == c_extended_type) {
                 VarDescExtendedType *etype =
                     reinterpret_cast<VarDescExtendedType*>(vars[i].into);
                 m_vars_extra[i].type_dst = etype->extended_type;