[File] [PATCH] encoding: Fix backward compatibility with 5.39

Anatol Belski ab at php.net
Sun Apr 4 20:10:27 UTC 2021


If a file contains just a short ascii string with repeating bytes, the
behavior won't be same as before 5.40. This ensures all the bytes have
been taken into account.

Signed-off-by: Anatol Belski <ab at php.net>
---
 src/encoding.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/encoding.c b/src/encoding.c
index c8b40439..bf28b997 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -283,7 +283,7 @@ looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \
 	u = 0; \
 	for (i = 0; i < __arraycount(dist); i++) { \
 		if (dist[i]) \
-			u++; \
+			u += dist[i]; \
 	} \
 	if (u < 3) \
 		return 0; \
-- 
2.30.2



More information about the File mailing list