@@ -2256,7 +2256,17 @@ class Framework {
22562256 }
22572257
22582258 uint8_t registerStream (const char *StreamName) {
2259- return (uint8_t )MStreamStringTable.add (StreamName);
2259+ xpti::string_id_t StreamID = MStreamStringTable.add (StreamName);
2260+
2261+ // string_id_t is uint32_t while return type is uint8_t, so we need to
2262+ // check if the ID is valid and fits into uint8_t.
2263+ if (StreamID == xpti::invalid_id<xpti::string_id_t >)
2264+ return xpti::invalid_id<uint8_t >;
2265+ else {
2266+ assert (StreamID < std::numeric_limits<uint8_t >::max () &&
2267+ " StreamID exceeds the maximum value for uint8_t" );
2268+ return static_cast <uint8_t >(StreamID);
2269+ }
22602270 }
22612271
22622272 // /
@@ -2284,7 +2294,17 @@ class Framework {
22842294 }
22852295
22862296 uint8_t registerVendor (const char *StreamName) {
2287- return (uint8_t )MVendorStringTable.add (StreamName);
2297+ xpti::string_id_t StreamID = MVendorStringTable.add (StreamName);
2298+
2299+ // string_id_t is uint32_t while return type is uint8_t, so we need to
2300+ // check if the ID is valid and fits into uint8_t.
2301+ if (StreamID == xpti::invalid_id<xpti::string_id_t >)
2302+ return xpti::invalid_id<uint8_t >;
2303+ else {
2304+ assert (StreamID < std::numeric_limits<uint8_t >::max () &&
2305+ " StreamID exceeds the maximum value for uint8_t" );
2306+ return static_cast <uint8_t >(StreamID);
2307+ }
22882308 }
22892309
22902310 string_id_t registerString (const char *String, char **TableString) {
0 commit comments