The "current character" bytes array was incremented at the end of the loop instead of at the beginning, which meant that for ASCII + .. /x80 it would complain about overrunning 0xFF->0x100 when in reality the loop would've ended just after. Instead, bump the current character at the start of the loop (but not the first time, of course), precisely as many times as there are characters in the range. Signed-off-by: Ahelenia ZiemiaƄska --- New patch, trivial and obvious off-by-1. locale/programs/charmap.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c index e4847aa3a0..822239ef11 100644 --- a/locale/programs/charmap.c +++ b/locale/programs/charmap.c @@ -1037,6 +1037,20 @@ hexadecimal range format should use only capital characters")); for (cnt = from_nr; cnt <= to_nr; cnt += step) { + /* Increment the value in the byte sequence. */ + if (cnt != from_nr && ++bytes[nbytes - 1] == '\0') + { + int b = nbytes - 2; + do + if (b < 0) + { + lr_error (lr, + _("resulting bytes for range not representable.")); + return; + } + while (++bytes[b--] == 0); + } + char *name_end; obstack_printf (ob, decimal_ellipsis ? "%.*s%0*d" : "%.*s%0*X", prefix_len, from, len1 - prefix_len, cnt); @@ -1079,21 +1093,6 @@ hexadecimal range format should use only capital characters")); insert_entry (bt, newp->bytes, nbytes, newp); /* Please note we don't examine the return value since it is no error if we have two definitions for a symbol. */ - - /* Increment the value in the byte sequence. */ - if (++bytes[nbytes - 1] == '\0') - { - int b = nbytes - 2; - - do - if (b < 0) - { - lr_error (lr, - _("resulting bytes for range not representable.")); - return; - } - while (++bytes[b--] == 0); - } } } -- 2.39.2