From 40941b41a4d9b4c3be93bba16301fe5c7041479e Mon Sep 17 00:00:00 2001 From: ANR2ME Date: Mon, 19 Apr 2021 05:48:37 +0700 Subject: [PATCH] Fix missing hex string at the last row when data size is a multiple of 16 bytes --- Common/StringUtils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index ee4478a5b4..b244c179ab 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -207,8 +207,10 @@ void DataToHexString(const char* prefix, uint32_t startAddr, const uint8_t* data for (size_t j = size; j < padded_size; j++) { buffer.Printf(" "); } + } + if (size > 0) { buffer.Printf(" "); - for (size_t j = size & ~UINT64_C(0xF); j < size; j++) { + for (size_t j = (size - 1ULL) & ~UINT64_C(0xF); j < size; j++) { buffer.Printf("%c", ((data[j] < 0x20) || (data[j] > 0x7e)) ? 0x2e : data[j]); } }