From a861d3c57f81a5389b09588c8ebd9f421c58ac7b Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Sun, 10 Apr 2016 02:21:41 +1200 Subject: [PATCH] Revert variable signedness changes. In the line: for (carry = bin[i], j = size - 1; (j > high) || carry; --j) my analysis missed that the compare (j > high) is always true when high is 0 and j wraps around. So although the loop does not store through a negative 'j' offset, it does require j to become negative in order to terminate the loop in that case. My apologies. --- base58.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base58.c b/base58.c index edc8f6a..33566e0 100644 --- a/base58.c +++ b/base58.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "libbase58.h" @@ -145,7 +146,8 @@ bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz) { const uint8_t *bin = data; int carry; - size_t i, j, size, high, zcount = 0; + ssize_t i, j, high, zcount = 0; + size_t size; while (zcount < binsz && !bin[zcount]) ++zcount;