Req #67386 [Opn->Nab]: wrong assignment in mbfl_identify_encoding2

From: Date: Sat, 22 Jul 2017 20:07:27 +0000
Subject: Req #67386 [Opn->Nab]: wrong assignment in mbfl_identify_encoding2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210203@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67386&edit=1 ID: 67386 Updated by: nikic@php.net Reported by: delda at virgilio dot it Summary: wrong assignment in mbfl_identify_encoding2 -Status: Open +Status: Not a bug Type: Feature/Change Request Package: mbstring related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The assignment is in the right place for what the code wants to do: If there are N possible encodings and N-1 of them have reported an error, then the code considers the last surviving one to be the correct one. Whether that makes sense is another question, see bug #72933. Previous Comments: ------------------------------------------------------------------------ [2014-07-05 23:08:22] yohgaki@php.net Could you send patch rather than whole file? or pull request? ------------------------------------------------------------------------ [2014-06-05 13:43:54] delda at virgilio dot it Description: ------------ I think that in the function 'mbfl_identify_encoding2' (in ext/mbstring/libmbfl/mbfl/mbfilter.c), the variable 'bad' was instantiated in a wrong place. The same is in 'mbfl_encoding_detector_feed' and 'mbfl_identify_encoding' Test script: --------------- if (p != NULL) { bad = 0; while (n > 0) { for (i = 0; i < num; i++) { [...] } if ((num - 1) <= bad && !strict) { break; } p++; n--; } } I think that 'bad' variable must be inner the while cycle, otherwise the if control on bad number detect is very poor. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67386&edit=1

« previous php.bugs (#210203) next »