From 34a033339786cdd0b7e427a9c30346dcc6260876 Mon Sep 17 00:00:00 2001 From: "n.savitchev" Date: Tue, 18 Jun 2024 18:25:21 +0300 Subject: [PATCH] fixed bug for windows-arm64 (introduced in https://github.com/google/cpu_features/pull/291 ) --- src/define_introspection.inl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/define_introspection.inl b/src/define_introspection.inl index c0eb916d..9bd0befe 100644 --- a/src/define_introspection.inl +++ b/src/define_introspection.inl @@ -71,6 +71,7 @@ static void (*const kSetters[])(FEAT_TYPE_NAME*, bool) = {INTROSPECTION_TABLE}; // Implements the `GetXXXFeaturesEnumValue` API. int GET_FEAT_ENUM_VALUE(const FEAT_TYPE_NAME* features, FEAT_ENUM_NAME value) { if (value >= FEAT_ENUM_LAST) return false; + if (value >= sizeof(kGetters)/sizeof(kGetters[0])) return false; return kGetters[value](features); } @@ -82,5 +83,6 @@ static const char* kFeatureNames[] = {INTROSPECTION_TABLE}; // Implements the `GetXXXFeaturesEnumName` API. const char* GET_FEAT_ENUM_NAME(FEAT_ENUM_NAME value) { if (value >= FEAT_ENUM_LAST) return "unknown_feature"; + if (value >= sizeof(kFeatureNames)/sizeof(kFeatureNames[0])) return "unknown_feature"; return kFeatureNames[value]; }