From baa5de4cd26ebf36cd288c8084f79b28e52843ce Mon Sep 17 00:00:00 2001 From: Martin Natano Date: Sun, 19 Sep 2021 22:07:31 +0200 Subject: [PATCH] Fix BinaryToHex() Previously the function stopped short on nul bytes ("\0") due to usage of the SArg() macro, which does not retrieve the length of the lua string. before the fix: `BinaryToHex("a\0b")` -> `"61"` after the fix: `BinaryToHex("a\0b")` -> `"610062"` --- src/RageUtil.cpp | 18 +++++++++++++++--- src/RageUtil.h | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/RageUtil.cpp b/src/RageUtil.cpp index 51f054f1aa..6a821c45dd 100644 --- a/src/RageUtil.cpp +++ b/src/RageUtil.cpp @@ -225,11 +225,11 @@ bool IsHexVal( const RString &s ) return true; } -RString BinaryToHex( const void *pData_, int iNumBytes ) +RString BinaryToHex( const void *pData_, size_t iNumBytes ) { const unsigned char *pData = (const unsigned char *) pData_; RString s; - for( int i=0; i