@@ -45,6 +45,8 @@ class TestPlatform : public TestFixture {
4545 TEST_CASE (invalid_config_file_3);
4646 TEST_CASE (invalid_config_file_4);
4747 TEST_CASE (invalid_config_file_5);
48+ TEST_CASE (invalid_config_file_6);
49+ TEST_CASE (invalid_config_file_7);
4850 TEST_CASE (empty_elements);
4951 TEST_CASE (default_platform);
5052 TEST_CASE (limitsDefines);
@@ -405,6 +407,57 @@ class TestPlatform : public TestFixture {
405407 ASSERT (!readPlatform (platform, xmldata));
406408 }
407409
410+ void invalid_config_file_6 () const {
411+ // getLimitsDefines() evaluates max_value(short_bit + 1) for USHRT_MAX, and the
412+ // parameter is a std::uint8_t, so a short width of 255 wraps to 0 there.
413+ constexpr char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
414+ " <platform>\n "
415+ " <windows>false</windows>\n "
416+ " <char_bit>85</char_bit>\n "
417+ " <default-sign>signed</default-sign>\n "
418+ " <sizeof>\n "
419+ " <bool>1</bool>\n "
420+ " <short>3</short>\n "
421+ " <int>1</int>\n "
422+ " <long>1</long>\n "
423+ " <long-long>1</long-long>\n "
424+ " <float>1</float>\n "
425+ " <double>1</double>\n "
426+ " <long-double>1</long-double>\n "
427+ " <pointer>1</pointer>\n "
428+ " <size_t>1</size_t>\n "
429+ " <wchar_t>1</wchar_t>\n "
430+ " </sizeof>\n "
431+ " </platform>" ;
432+ PlatformTest platform;
433+ ASSERT (!readPlatform (platform, xmldata));
434+ }
435+
436+ void invalid_config_file_7 () const {
437+ // The same for max_value(int_bit + 1), which getLimitsDefines() uses for UINT_MAX.
438+ constexpr char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
439+ " <platform>\n "
440+ " <windows>false</windows>\n "
441+ " <char_bit>1</char_bit>\n "
442+ " <default-sign>signed</default-sign>\n "
443+ " <sizeof>\n "
444+ " <bool>1</bool>\n "
445+ " <short>1</short>\n "
446+ " <int>255</int>\n "
447+ " <long>255</long>\n "
448+ " <long-long>255</long-long>\n "
449+ " <float>1</float>\n "
450+ " <double>1</double>\n "
451+ " <long-double>1</long-double>\n "
452+ " <pointer>1</pointer>\n "
453+ " <size_t>1</size_t>\n "
454+ " <wchar_t>1</wchar_t>\n "
455+ " </sizeof>\n "
456+ " </platform>" ;
457+ PlatformTest platform;
458+ ASSERT (!readPlatform (platform, xmldata));
459+ }
460+
408461 void invalid_config_file_1 () const {
409462 // Invalid XML file: mismatching elements "boolt" vs "bool".
410463 constexpr char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
0 commit comments