From: Daniel Arndt Date: Sun, 29 Apr 2018 23:11:36 +0000 (+0200) Subject: Avoid accessing invalid memory in base/utilities_pack_unpack_04 X-Git-Tag: v9.0.0-rc1~62^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06d6fa187e030f036d70426ba3ce679710b50c59;p=dealii.git Avoid accessing invalid memory in base/utilities_pack_unpack_04 --- diff --git a/tests/base/utilities_pack_unpack_04.cc b/tests/base/utilities_pack_unpack_04.cc index 5c9a74f860..3546ec90fa 100644 --- a/tests/base/utilities_pack_unpack_04.cc +++ b/tests/base/utilities_pack_unpack_04.cc @@ -34,8 +34,10 @@ void check (const T (&object)[N]) T unpacked[N]; Utilities::unpack(buffer, unpacked); - deallog << "Buffer size check: " << (buffer.size() == sizeof(T)*N ? "OK" : "Failed") << std::endl; - deallog << "memcmp check: " << (std::memcmp(buffer.data(), &object, buffer.size()) == 0 ? "OK" : "Failed") << std::endl; + const bool equal_sizes = (buffer.size() == sizeof(T)*N); + deallog << "Buffer size check: " << (equal_sizes ? "OK" : "Failed") << std::endl; + if (equal_sizes) + deallog << "memcmp check: " << (std::memcmp(buffer.data(), &object, buffer.size()) == 0 ? "OK" : "Failed") << std::endl; bool equal=true; for (unsigned int i=0; i