Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use bounds checking method array::at().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 15:25:23 +0000 (16:25 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 17:29:25 +0000 (18:29 +0100)
include/xbt/utility.hpp
src/simix/libsmx.cpp

index 22da5d15a56744a97ff849f3167e5413369ef254..d0d73022ff017b2d2ada7f2080737cf34f43efdb 100644 (file)
@@ -22,7 +22,7 @@
   static constexpr char const* to_c_str(EnumType value)                                                                \
   {                                                                                                                    \
     constexpr std::array<const char*, _XBT_COUNT_ARGS(__VA_ARGS__)> names{{_XBT_STRINGIFY_ARGS(__VA_ARGS__)}};         \
   static constexpr char const* to_c_str(EnumType value)                                                                \
   {                                                                                                                    \
     constexpr std::array<const char*, _XBT_COUNT_ARGS(__VA_ARGS__)> names{{_XBT_STRINGIFY_ARGS(__VA_ARGS__)}};         \
-    return names[static_cast<int>(value)];                                                                             \
+    return names.at(static_cast<int>(value));                                                                          \
   }                                                                                                                    \
   enum class EnumType { __VA_ARGS__ } /* defined here to handle trailing semicolon */
 
   }                                                                                                                    \
   enum class EnumType { __VA_ARGS__ } /* defined here to handle trailing semicolon */
 
index 0dd298f2b9a45de0c92f965bdf3268f2dab1461d..3d7a70de6484f27579e0e76aeac3ed296b9e8ac7 100644 (file)
@@ -224,7 +224,7 @@ const char* SIMIX_simcall_name(const s_smx_simcall& simcall)
       cname += 17; // strip prefix "simgrid::kernel::"
     return cname;
   } else {
       cname += 17; // strip prefix "simgrid::kernel::"
     return cname;
   } else {
-    return simcall_names[static_cast<int>(simcall.call_)];
+    return simcall_names.at(static_cast<int>(simcall.call_));
   }
 }
 
   }
 }