From 6800a95ef32826e753881802a2c126c59d451397 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 8 May 2024 01:43:44 -0500 Subject: [PATCH] Ray Gardner pointed out we were adding the +4 to the wrong side of the strlower() check for unicode facepalm. With test. --- lib/lib.c | 2 +- tests/find.test | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/lib.c b/lib/lib.c index 6a4a77dd..9561848a 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -432,7 +432,7 @@ char *strlower(char *s) // Case conversion can expand utf8 representation, but with extra mlen // space above we should basically never need to realloc - if (mlen+4 > (len = new-try)) continue; + if (mlen > (len = new-try)+4) continue; try = xrealloc(try, mlen = len+16); new = try+len; } diff --git a/tests/find.test b/tests/find.test index 862edc93..e026d7b5 100755 --- a/tests/find.test +++ b/tests/find.test @@ -160,3 +160,8 @@ ln -s one dir/three testing '-size implies -type f' 'find dir -size -1M | sort' \ 'dir/one\ndir/two\n' '' '' rm -rf dir + +utf8locale +testing 'strlower edge case' \ + 'touch aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ; find . -iname aaaaaȺȺȺȺȺȺȺȺȺ' './aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ\n' \ + '' '' -- 2.39.2