chiark / gitweb /
correct hex() for 0 length outputs
[disorder] / lib / hex.c
index d2a2a0021f96d8e39ec87bcabe6ff2627d31ebab..f37db111354f87999e48d1ef249d64daef0d7511 100644 (file)
--- a/lib/hex.c
+++ b/lib/hex.c
@@ -33,6 +33,7 @@ char *hex(const uint8_t *ptr, size_t n) {
 
   while(n-- > 0)
     p += sprintf(p, "%02x", (unsigned)*ptr++);
+  *p = 0;
   return buf;
 }
 
@@ -91,4 +92,3 @@ c-basic-offset:2
 comment-column:40
 End:
 */
-/* arch-tag:3d2adfde608c6d54dc2cf2b42d78e462 */