Found a small correctness issue in LogEscape():
-
When char is signed (common on x86_64 Linux), negative byte values (e.g. 0xFF = -1) were being printed as ffffffff instead of ff.
-
This fixes it by casting to unsigned char before %02x.
-
Also changed the hardcoded 4 to sizeof(escape) so the code doesn’t break silently if someone increases the buffer size later.
No performance impact, just safer and more portable.