Issue #10: Crashing sequence with nsSJISProber.

uchardet_handle_data() should not try to process data of nul length.

Still this is not technically an error to feed empty data to the engine,
and I could imagine it could happen especially when done in some
automatic process with random input files (which looks like what was
happening in the reporter case). So feeding empty data just returns a
success without actually doing any processing, allowing to continue the
data feed.
This commit is contained in:
Jehan 2020-04-22 22:11:51 +02:00
parent ef0313046b
commit 6c7f32a751

View File

@ -91,7 +91,11 @@ void uchardet_delete(uchardet_t ud)
int uchardet_handle_data(uchardet_t ud, const char * data, size_t len)
{
nsresult ret = reinterpret_cast<HandleUniversalDetector*>(ud)->HandleData(data, (PRUint32)len);
nsresult ret = NS_OK;
if (len > 0)
ret = reinterpret_cast<HandleUniversalDetector*>(ud)->HandleData(data, (PRUint32)len);
return (ret != NS_OK);
}