# HG changeset patch # User stuefe # Date 1476336338 -7200 # Thu Oct 13 07:25:38 2016 +0200 # Node ID e2cd6567f3b1cfa3d3f3b7539ae46b3fdafaddca # Parent b1c62e595c4ac0a3256296b8c13d871db9003fe8 8167650: NMT should check for invalid MEMFLAGS Reviewed-by: diff --git a/src/share/vm/services/nmtCommon.hpp b/src/share/vm/services/nmtCommon.hpp --- a/src/share/vm/services/nmtCommon.hpp +++ b/src/share/vm/services/nmtCommon.hpp @@ -55,16 +55,19 @@ public: // Map memory type to index static inline int flag_to_index(MEMFLAGS flag) { + assert(flag >= 0 && flag < mt_number_of_types, "Invalid flag value %d.", (int)flag); return (flag & 0xff); } // Map memory type to human readable name static const char* flag_to_name(MEMFLAGS flag) { + assert(flag >= 0 && flag < mt_number_of_types, "Invalid flag value %d.", (int)flag); return _memory_type_names[flag_to_index(flag)]; } // Map an index to memory type static MEMFLAGS index_to_flag(int index) { + assert(index >= 0 && index < (int) mt_number_of_types, "Invalid index value %d.", index); return (MEMFLAGS)index; }