summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hex.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hex.c b/hex.c
index e03ddc97..80f0009a 100644
--- a/hex.c
+++ b/hex.c
@@ -54,7 +54,7 @@ const char *gpsd_hexdump(char *scbuf, size_t scbuflen,
if (NULL == binbuf || 0 == binbuflen)
return "";
- for (i = 0; i < len && i * 2 < scbuflen - 2; i++) {
+ for (i = 0; i < len && j < (scbuflen - 3); i++) {
scbuf[j++] = hexchar[(ibuf[i] & 0xf0) >> 4];
scbuf[j++] = hexchar[ibuf[i] & 0x0f];
}