From a1e58728e5cf9b97d6adbc4d6c90267ec4ae7869 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 2 Jun 2013 10:39:10 +0000 Subject: StringUtils: Fixed the HexDump in DEBUG mode git-svn-id: http://mc-server.googlecode.com/svn/trunk@1538 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/StringUtils.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/StringUtils.cpp') diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp index 0143bb8c4..536281054 100644 --- a/source/StringUtils.cpp +++ b/source/StringUtils.cpp @@ -526,12 +526,14 @@ AString & CreateHexDump(AString & a_Out, const void * a_Data, int a_Size, int a_ { k = a_LineLength; } - memset(line, ' ', sizeof(line)); - #ifdef _MSC_VER // MSVC provides a "secure" version of sprintf() - line[sprintf_s(line, sizeof(line), "%08x:", i)] = 32; // Remove the terminating NULL that sprintf puts there + #ifdef _MSC_VER + // MSVC provides a "secure" version of sprintf() + int Count = sprintf_s(line, sizeof(line), "%08x:", i); #else - line[sprintf(line, "%08x:", i)] = 32; // Remove the terminating NULL that sprintf puts there + int Count = sprintf(line, "%08x:", i); #endif + // Remove the terminating NULL / leftover garbage in line, after the sprintf-ed value + memset(line + Count, 32, sizeof(line) - Count); p = line + 10; q = p + 2 + a_LineLength * 3 + 1; for (int j = 0; j < k; j++) -- cgit v1.2.3