Skip to content

Commit

Permalink
Replace test with invalid-enum-load (#2546)
Browse files Browse the repository at this point in the history
The TestTypeSizeOf was casting an invalid value for TfLiteType into a variable of that type. This is undefined behavior and triggered ubsan. This PR replaces this test case with using kTfLiteNoType, which will still trigger the default failure case for TfLiteTypeSizeOf.

BUG=b/333708102
  • Loading branch information
rascani authored Apr 17, 2024
1 parent deec0d8 commit 26fbc4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tensorflow/lite/micro/memory_helpers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ TF_LITE_MICRO_TEST(TestTypeSizeOf) {
tflite::TfLiteTypeSizeOf(kTfLiteComplex128, &size));
TF_LITE_MICRO_EXPECT_EQ(sizeof(double) * 2, size);

TF_LITE_MICRO_EXPECT_NE(
kTfLiteOk, tflite::TfLiteTypeSizeOf(static_cast<TfLiteType>(-1), &size));
TF_LITE_MICRO_EXPECT_NE(kTfLiteOk,
tflite::TfLiteTypeSizeOf(kTfLiteNoType, &size));
}

TF_LITE_MICRO_TEST(TestBytesRequiredForTensor) {
Expand Down

0 comments on commit 26fbc4b

Please sign in to comment.