Fix unsafe buffer usage in fxbarcode/datamatrix. -- convert to std::array<> where indexing required. -- use spans of chars in place of C-style pointer. Change-Id: I41804397a4a8e4913f13e38c00bc19e6d1e4e58b Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118110 Reviewed-by: Thomas Sepez <tsepez@google.com> Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp index 215ffae..1720f2e 100644 --- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp +++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
@@ -24,6 +24,7 @@ #include <optional> +#include "core/fxcrt/compiler_specific.h" #include "core/fxcrt/fx_extension.h" #include "fxbarcode/datamatrix/BC_Encoder.h" #include "fxbarcode/datamatrix/BC_EncoderContext.h" @@ -47,11 +48,17 @@ size_t count = 0; const size_t size = msg.GetLength(); const wchar_t* data = msg.c_str(); - for (size_t i = startpos; i < size; ++i) { - if (!FXSYS_IsDecimalDigit(data[i])) - break; - ++count; - } + + // SAFETY: performance-sensitive. + UNSAFE_BUFFERS({ + for (size_t i = startpos; i < size; ++i) { + if (!FXSYS_IsDecimalDigit(data[i])) { + break; + } + ++count; + } + }); + return count; }
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp index 9613107..6e87aab 100644 --- a/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp +++ b/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp
@@ -7,8 +7,11 @@ #include <stdint.h> #include "core/fxcrt/data_vector.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using testing::ElementsAreArray; + class CBC_DataMatrixWriterTest : public testing::Test { public: CBC_DataMatrixWriterTest() = default; @@ -44,8 +47,7 @@ ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < std::size(kExpectedData); ++i) - EXPECT_EQ(kExpectedData[i], data[i]) << i; + EXPECT_THAT(data, ElementsAreArray(kExpectedData)); } { static constexpr int kExpectedDimension = 14; @@ -71,8 +73,7 @@ ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < std::size(kExpectedData); ++i) - EXPECT_EQ(kExpectedData[i], data[i]) << i; + EXPECT_THAT(data, ElementsAreArray(kExpectedData)); } { static constexpr int kExpectedDimension = 10; @@ -94,8 +95,7 @@ ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < std::size(kExpectedData); ++i) - EXPECT_EQ(kExpectedData[i], data[i]) << i; + EXPECT_THAT(data, ElementsAreArray(kExpectedData)); } { static constexpr int kExpectedDimension = 18; @@ -126,8 +126,7 @@ ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < std::size(kExpectedData); ++i) - EXPECT_EQ(kExpectedData[i], data[i]) << i; + EXPECT_THAT(data, ElementsAreArray(kExpectedData)); } { DataVector<uint8_t> data = writer.Encode(L"hello world", &width, &height);
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp index 8411445..2b5d567 100644 --- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp +++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -25,133 +25,139 @@ #include <stdint.h> #include <algorithm> +#include <array> #include <vector> #include "core/fxcrt/check.h" #include "core/fxcrt/fixed_size_data_vector.h" +#include "core/fxcrt/span.h" #include "fxbarcode/datamatrix/BC_Encoder.h" #include "fxbarcode/datamatrix/BC_SymbolInfo.h" namespace { -const uint8_t FACTOR_SETS[] = {5, 7, 10, 11, 12, 14, 18, 20, - 24, 28, 36, 42, 48, 56, 62, 68}; +constexpr std::array<uint8_t, 5> FACTORS_0 = {{228, 48, 15, 111, 62}}; -const uint8_t FACTORS_0[5] = {228, 48, 15, 111, 62}; -const uint8_t FACTORS_1[7] = {23, 68, 144, 134, 240, 92, 254}; -const uint8_t FACTORS_2[10] = {28, 24, 185, 166, 223, 248, 116, 255, 110, 61}; -const uint8_t FACTORS_3[11] = {175, 138, 205, 12, 194, 168, - 39, 245, 60, 97, 120}; +constexpr std::array<uint8_t, 7> FACTORS_1 = {{23, 68, 144, 134, 240, 92, 254}}; -const uint8_t FACTORS_4[12] = {41, 153, 158, 91, 61, 42, - 142, 213, 97, 178, 100, 242}; +constexpr std::array<uint8_t, 10> FACTORS_2 = { + {28, 24, 185, 166, 223, 248, 116, 255, 110, 61}}; -const uint8_t FACTORS_5[14] = {156, 97, 192, 252, 95, 9, 157, - 119, 138, 45, 18, 186, 83, 185}; +constexpr std::array<uint8_t, 11> FACTORS_3 = { + {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120}}; -const uint8_t FACTORS_6[18] = {83, 195, 100, 39, 188, 75, 66, 61, 241, - 213, 109, 129, 94, 254, 225, 48, 90, 188}; +constexpr std::array<uint8_t, 12> FACTORS_4 = { + {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242}}; -const uint8_t FACTORS_7[20] = {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, - 153, 145, 253, 79, 108, 82, 27, 174, 186, 172}; +constexpr std::array<uint8_t, 14> FACTORS_5 = { + {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185}}; -const uint8_t FACTORS_8[24] = {52, 190, 88, 205, 109, 39, 176, 21, - 155, 197, 251, 223, 155, 21, 5, 172, - 254, 124, 12, 181, 184, 96, 50, 193}; +constexpr std::array<uint8_t, 18> FACTORS_6 = {{83, 195, 100, 39, 188, 75, 66, + 61, 241, 213, 109, 129, 94, 254, + 225, 48, 90, 188}}; -const uint8_t FACTORS_9[28] = {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, - 170, 53, 75, 34, 249, 121, 17, 138, 110, 213, - 141, 136, 120, 151, 233, 168, 93, 255}; +constexpr std::array<uint8_t, 20> FACTORS_7 = { + {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, + 153, 145, 253, 79, 108, 82, 27, 174, 186, 172}}; -const uint8_t FACTORS_10[36] = {245, 127, 242, 218, 130, 250, 162, 181, 102, - 120, 84, 179, 220, 251, 80, 182, 229, 18, - 2, 4, 68, 33, 101, 137, 95, 119, 115, - 44, 175, 184, 59, 25, 225, 98, 81, 112}; +constexpr std::array<uint8_t, 24> FACTORS_8 = { + {52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, + 155, 21, 5, 172, 254, 124, 12, 181, 184, 96, 50, 193}}; -const uint8_t FACTORS_11[42] = { - 77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, - 242, 8, 175, 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, - 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5, 9, 5}; +constexpr std::array<uint8_t, 28> FACTORS_9 = { + {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, + 249, 121, 17, 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255}}; -const uint8_t FACTORS_12[48] = { - 245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, - 205, 188, 237, 87, 191, 106, 16, 147, 118, 23, 37, 90, - 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, - 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19}; +constexpr std::array<uint8_t, 36> FACTORS_10 = { + {245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, + 220, 251, 80, 182, 229, 18, 2, 4, 68, 33, 101, 137, + 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112}}; -const uint8_t FACTORS_13[56] = { - 175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, - 215, 235, 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, - 117, 203, 29, 232, 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, - 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46}; +constexpr std::array<uint8_t, 42> FACTORS_11 = { + {77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, + 242, 8, 175, 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, + 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5, 9, 5}}; -const uint8_t FACTORS_14[62] = { - 242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, - 108, 196, 37, 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, - 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51, - 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, - 232, 7, 94, 166, 224, 124, 86, 47, 11, 204}; +constexpr std::array<uint8_t, 48> FACTORS_12 = { + {245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, + 205, 188, 237, 87, 191, 106, 16, 147, 118, 23, 37, 90, + 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, + 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19}}; -const uint8_t FACTORS_15[68] = { - 220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, - 73, 127, 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, - 15, 160, 227, 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, - 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, - 211, 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186}; +constexpr std::array<uint8_t, 56> FACTORS_13 = { + {175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, + 215, 235, 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, + 117, 203, 29, 232, 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, + 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46}}; -const uint8_t* const FACTORS[16] = { - FACTORS_0, FACTORS_1, FACTORS_2, FACTORS_3, FACTORS_4, FACTORS_5, - FACTORS_6, FACTORS_7, FACTORS_8, FACTORS_9, FACTORS_10, FACTORS_11, - FACTORS_12, FACTORS_13, FACTORS_14, FACTORS_15}; +constexpr std::array<uint8_t, 62> FACTORS_14 = { + {242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, + 108, 196, 37, 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, + 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51, + 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, + 232, 7, 94, 166, 224, 124, 86, 47, 11, 204}}; -constexpr uint8_t LOG[256] = { - 0, 0, 1, 240, 2, 225, 241, 53, 3, 38, 226, 133, 242, 43, 54, - 210, 4, 195, 39, 114, 227, 106, 134, 28, 243, 140, 44, 23, 55, 118, - 211, 234, 5, 219, 196, 96, 40, 222, 115, 103, 228, 78, 107, 125, 135, - 8, 29, 162, 244, 186, 141, 180, 45, 99, 24, 49, 56, 13, 119, 153, - 212, 199, 235, 91, 6, 76, 220, 217, 197, 11, 97, 184, 41, 36, 223, - 253, 116, 138, 104, 193, 229, 86, 79, 171, 108, 165, 126, 145, 136, 34, - 9, 74, 30, 32, 163, 84, 245, 173, 187, 204, 142, 81, 181, 190, 46, - 88, 100, 159, 25, 231, 50, 207, 57, 147, 14, 67, 120, 128, 154, 248, - 213, 167, 200, 63, 236, 110, 92, 176, 7, 161, 77, 124, 221, 102, 218, - 95, 198, 90, 12, 152, 98, 48, 185, 179, 42, 209, 37, 132, 224, 52, - 254, 239, 117, 233, 139, 22, 105, 27, 194, 113, 230, 206, 87, 158, 80, - 189, 172, 203, 109, 175, 166, 62, 127, 247, 146, 66, 137, 192, 35, 252, - 10, 183, 75, 216, 31, 83, 33, 73, 164, 144, 85, 170, 246, 65, 174, - 61, 188, 202, 205, 157, 143, 169, 82, 72, 182, 215, 191, 251, 47, 178, - 89, 151, 101, 94, 160, 123, 26, 112, 232, 21, 51, 238, 208, 131, 58, - 69, 148, 18, 15, 16, 68, 17, 121, 149, 129, 19, 155, 59, 249, 70, - 214, 250, 168, 71, 201, 156, 64, 60, 237, 130, 111, 20, 93, 122, 177, - 150}; +constexpr std::array<uint8_t, 68> FACTORS_15 = { + {220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, + 73, 127, 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, + 15, 160, 227, 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, + 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, + 211, 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186}}; -constexpr uint8_t ALOG[256] = { - 1, 2, 4, 8, 16, 32, 64, 128, 45, 90, 180, 69, 138, 57, 114, - 228, 229, 231, 227, 235, 251, 219, 155, 27, 54, 108, 216, 157, 23, 46, - 92, 184, 93, 186, 89, 178, 73, 146, 9, 18, 36, 72, 144, 13, 26, - 52, 104, 208, 141, 55, 110, 220, 149, 7, 14, 28, 56, 112, 224, 237, - 247, 195, 171, 123, 246, 193, 175, 115, 230, 225, 239, 243, 203, 187, 91, - 182, 65, 130, 41, 82, 164, 101, 202, 185, 95, 190, 81, 162, 105, 210, - 137, 63, 126, 252, 213, 135, 35, 70, 140, 53, 106, 212, 133, 39, 78, - 156, 21, 42, 84, 168, 125, 250, 217, 159, 19, 38, 76, 152, 29, 58, - 116, 232, 253, 215, 131, 43, 86, 172, 117, 234, 249, 223, 147, 11, 22, - 44, 88, 176, 77, 154, 25, 50, 100, 200, 189, 87, 174, 113, 226, 233, - 255, 211, 139, 59, 118, 236, 245, 199, 163, 107, 214, 129, 47, 94, 188, - 85, 170, 121, 242, 201, 191, 83, 166, 97, 194, 169, 127, 254, 209, 143, - 51, 102, 204, 181, 71, 142, 49, 98, 196, 165, 103, 206, 177, 79, 158, - 17, 34, 68, 136, 61, 122, 244, 197, 167, 99, 198, 161, 111, 222, 145, - 15, 30, 60, 120, 240, 205, 183, 67, 134, 33, 66, 132, 37, 74, 148, - 5, 10, 20, 40, 80, 160, 109, 218, 153, 31, 62, 124, 248, 221, 151, - 3, 6, 12, 24, 48, 96, 192, 173, 119, 238, 241, 207, 179, 75, 150, - 0}; +constexpr std::array<pdfium::span<const uint8_t>, 16> FACTORS = { + {FACTORS_0, FACTORS_1, FACTORS_2, FACTORS_3, FACTORS_4, FACTORS_5, + FACTORS_6, FACTORS_7, FACTORS_8, FACTORS_9, FACTORS_10, FACTORS_11, + FACTORS_12, FACTORS_13, FACTORS_14, FACTORS_15}}; + +constexpr std::array<uint8_t, 256> LOG = { + {0, 0, 1, 240, 2, 225, 241, 53, 3, 38, 226, 133, 242, 43, 54, + 210, 4, 195, 39, 114, 227, 106, 134, 28, 243, 140, 44, 23, 55, 118, + 211, 234, 5, 219, 196, 96, 40, 222, 115, 103, 228, 78, 107, 125, 135, + 8, 29, 162, 244, 186, 141, 180, 45, 99, 24, 49, 56, 13, 119, 153, + 212, 199, 235, 91, 6, 76, 220, 217, 197, 11, 97, 184, 41, 36, 223, + 253, 116, 138, 104, 193, 229, 86, 79, 171, 108, 165, 126, 145, 136, 34, + 9, 74, 30, 32, 163, 84, 245, 173, 187, 204, 142, 81, 181, 190, 46, + 88, 100, 159, 25, 231, 50, 207, 57, 147, 14, 67, 120, 128, 154, 248, + 213, 167, 200, 63, 236, 110, 92, 176, 7, 161, 77, 124, 221, 102, 218, + 95, 198, 90, 12, 152, 98, 48, 185, 179, 42, 209, 37, 132, 224, 52, + 254, 239, 117, 233, 139, 22, 105, 27, 194, 113, 230, 206, 87, 158, 80, + 189, 172, 203, 109, 175, 166, 62, 127, 247, 146, 66, 137, 192, 35, 252, + 10, 183, 75, 216, 31, 83, 33, 73, 164, 144, 85, 170, 246, 65, 174, + 61, 188, 202, 205, 157, 143, 169, 82, 72, 182, 215, 191, 251, 47, 178, + 89, 151, 101, 94, 160, 123, 26, 112, 232, 21, 51, 238, 208, 131, 58, + 69, 148, 18, 15, 16, 68, 17, 121, 149, 129, 19, 155, 59, 249, 70, + 214, 250, 168, 71, 201, 156, 64, 60, 237, 130, 111, 20, 93, 122, 177, + 150}}; + +constexpr std::array<uint8_t, 256> ALOG = { + {1, 2, 4, 8, 16, 32, 64, 128, 45, 90, 180, 69, 138, 57, 114, + 228, 229, 231, 227, 235, 251, 219, 155, 27, 54, 108, 216, 157, 23, 46, + 92, 184, 93, 186, 89, 178, 73, 146, 9, 18, 36, 72, 144, 13, 26, + 52, 104, 208, 141, 55, 110, 220, 149, 7, 14, 28, 56, 112, 224, 237, + 247, 195, 171, 123, 246, 193, 175, 115, 230, 225, 239, 243, 203, 187, 91, + 182, 65, 130, 41, 82, 164, 101, 202, 185, 95, 190, 81, 162, 105, 210, + 137, 63, 126, 252, 213, 135, 35, 70, 140, 53, 106, 212, 133, 39, 78, + 156, 21, 42, 84, 168, 125, 250, 217, 159, 19, 38, 76, 152, 29, 58, + 116, 232, 253, 215, 131, 43, 86, 172, 117, 234, 249, 223, 147, 11, 22, + 44, 88, 176, 77, 154, 25, 50, 100, 200, 189, 87, 174, 113, 226, 233, + 255, 211, 139, 59, 118, 236, 245, 199, 163, 107, 214, 129, 47, 94, 188, + 85, 170, 121, 242, 201, 191, 83, 166, 97, 194, 169, 127, 254, 209, 143, + 51, 102, 204, 181, 71, 142, 49, 98, 196, 165, 103, 206, 177, 79, 158, + 17, 34, 68, 136, 61, 122, 244, 197, 167, 99, 198, 161, 111, 222, 145, + 15, 30, 60, 120, 240, 205, 183, 67, 134, 33, 66, 132, 37, 74, 148, + 5, 10, 20, 40, 80, 160, 109, 218, 153, 31, 62, 124, 248, 221, 151, + 3, 6, 12, 24, 48, 96, 192, 173, 119, 238, 241, 207, 179, 75, 150, + 0}}; WideString CreateECCBlock(const WideString& codewords, size_t numECWords) { DCHECK(numECWords > 0); const size_t len = codewords.GetLength(); - static constexpr size_t kFactorTableNum = std::size(FACTOR_SETS); + static constexpr size_t kFactorTableNum = std::size(FACTORS); size_t table = 0; - while (table < kFactorTableNum && FACTOR_SETS[table] != numECWords) + while (table < kFactorTableNum && FACTORS[table].size() != numECWords) { ++table; + } if (table >= kFactorTableNum) return WideString();
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp index ed931c0..efcd5e4 100644 --- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp +++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -22,6 +22,7 @@ #include "fxbarcode/datamatrix/BC_SymbolInfo.h" +#include <array> #include <iterator> #include "core/fxcrt/notreached.h" @@ -32,32 +33,26 @@ namespace { constexpr size_t kSymbolsCount = 30; +constexpr size_t kSymbolDataSize = kSymbolsCount - 1; -CBC_SymbolInfo* g_symbols[kSymbolsCount] = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; +std::array<CBC_SymbolInfo*, kSymbolsCount> g_symbols = {}; -constexpr CBC_SymbolInfo::Data kSymbolData[] = { - {3, 5, 3, 5, 8, 8, 1}, {5, 7, 5, 7, 10, 10, 1}, - {5, 7, 5, 7, 16, 6, 1}, {8, 10, 8, 10, 12, 12, 1}, - {10, 11, 10, 11, 14, 6, 2}, {12, 12, 12, 12, 14, 14, 1}, - {16, 14, 16, 14, 24, 10, 1}, {18, 14, 18, 14, 16, 16, 1}, - {22, 18, 22, 18, 18, 18, 1}, {22, 18, 22, 18, 16, 10, 2}, - {30, 20, 30, 20, 20, 20, 1}, {32, 24, 32, 24, 16, 14, 2}, - {36, 24, 36, 24, 22, 22, 1}, {44, 28, 44, 28, 24, 24, 1}, - {49, 28, 49, 28, 22, 14, 2}, {62, 36, 62, 36, 14, 14, 4}, - {86, 42, 86, 42, 16, 16, 4}, {114, 48, 114, 48, 18, 18, 4}, - {144, 56, 144, 56, 20, 20, 4}, {174, 68, 174, 68, 22, 22, 4}, - {204, 84, 102, 42, 24, 24, 4}, {280, 112, 140, 56, 14, 14, 16}, - {368, 144, 92, 36, 16, 16, 16}, {456, 192, 114, 48, 18, 18, 16}, - {576, 224, 144, 56, 20, 20, 16}, {696, 272, 174, 68, 22, 22, 16}, - {816, 336, 136, 56, 24, 24, 16}, {1050, 408, 175, 68, 18, 18, 36}, - {1304, 496, 163, 62, 20, 20, 36}}; - -constexpr size_t kSymbolDataSize = std::size(kSymbolData); -static_assert(kSymbolDataSize + 1 == kSymbolsCount, "Wrong kSymbolDataSize"); +constexpr std::array<CBC_SymbolInfo::Data, kSymbolDataSize> kSymbolData = { + {{3, 5, 3, 5, 8, 8, 1}, {5, 7, 5, 7, 10, 10, 1}, + {5, 7, 5, 7, 16, 6, 1}, {8, 10, 8, 10, 12, 12, 1}, + {10, 11, 10, 11, 14, 6, 2}, {12, 12, 12, 12, 14, 14, 1}, + {16, 14, 16, 14, 24, 10, 1}, {18, 14, 18, 14, 16, 16, 1}, + {22, 18, 22, 18, 18, 18, 1}, {22, 18, 22, 18, 16, 10, 2}, + {30, 20, 30, 20, 20, 20, 1}, {32, 24, 32, 24, 16, 14, 2}, + {36, 24, 36, 24, 22, 22, 1}, {44, 28, 44, 28, 24, 24, 1}, + {49, 28, 49, 28, 22, 14, 2}, {62, 36, 62, 36, 14, 14, 4}, + {86, 42, 86, 42, 16, 16, 4}, {114, 48, 114, 48, 18, 18, 4}, + {144, 56, 144, 56, 20, 20, 4}, {174, 68, 174, 68, 22, 22, 4}, + {204, 84, 102, 42, 24, 24, 4}, {280, 112, 140, 56, 14, 14, 16}, + {368, 144, 92, 36, 16, 16, 16}, {456, 192, 114, 48, 18, 18, 16}, + {576, 224, 144, 56, 20, 20, 16}, {696, 272, 174, 68, 22, 22, 16}, + {816, 336, 136, 56, 24, 24, 16}, {1050, 408, 175, 68, 18, 18, 36}, + {1304, 496, 163, 62, 20, 20, 36}}}; } // namespace