Skip to content

Commit

Permalink
ExchangeTypeNames avoid illegal memory access
Browse files Browse the repository at this point in the history
Avoid that we access memory outside of the naming array.
  • Loading branch information
psychocoderHPC committed Mar 19, 2019
1 parent 69e77eb commit 3e19311
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/pmacc/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

#include <stdint.h>
#include <stdexcept>
#include <string>


namespace pmacc
Expand Down Expand Up @@ -149,6 +150,9 @@ struct ExchangeTypeNames
{
std::string operator[]( const uint32_t exchange ) const
{
if( exchange >= 27 )
return std::string("unknown exchange type: ") + std::to_string(exchange);

const char* names[27] = {
"none",
"right", "left", "bottom",
Expand Down

0 comments on commit 3e19311

Please sign in to comment.