diff --git a/projects/clr/rocclr/device/devhcprintf.cpp b/projects/clr/rocclr/device/devhcprintf.cpp index ff723ff580..ea5adcbe85 100644 --- a/projects/clr/rocclr/device/devhcprintf.cpp +++ b/projects/clr/rocclr/device/devhcprintf.cpp @@ -64,8 +64,10 @@ template static const uint64_t* consumeCstring(FILE* stream, int* outCount, const std::string& spec, const uint64_t* ptr, Args... args) { auto str = reinterpret_cast(ptr); + auto old = *outCount; checkPrintf(stream, outCount, spec.c_str(), args..., str); - return ptr + (strlen(str) + 7) / 8; + auto stringMemSize = *outCount - old + 1; + return ptr + (stringMemSize + 7) / 8; } template