From 2871411902966603581d3c8ce86a4aa89d3b7229 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Fri, 5 Apr 2019 10:08:44 -0700 Subject: [PATCH] zip_writer_test.cc: fix implicit integer truncation converting from a size_t to a uint8_t results in a loss of precision, which triggers ubsan's implicit-unsigned-integer-truncation checker. Make the conversion explicit. This change allows the ziparchive-tests to pass with ubsan enabled. Test: atest ziparchive-tests Test: compiles and boots Bug: 122975762 Change-Id: I63f28b58f1ca1f4c57323494cb1f4a41e0f34fba --- libziparchive/zip_writer_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libziparchive/zip_writer_test.cc b/libziparchive/zip_writer_test.cc index c2842734e..7322afb1e 100644 --- a/libziparchive/zip_writer_test.cc +++ b/libziparchive/zip_writer_test.cc @@ -257,7 +257,7 @@ TEST_F(zipwriter, WriteCompressedZipFlushFull) { std::vector buffer(kBufSize); size_t prev = 1; for (size_t i = 0; i < kBufSize; i++) { - buffer[i] = i + prev; + buffer[i] = static_cast(i + prev); prev = i; }