summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehan <jehan@girinstud.io>2020-04-22 22:11:51 +0200
committerJehan <jehan@girinstud.io>2020-04-22 22:11:51 +0200
commit6c7f32a75106b1c6f464b0f04f583590fa574fee (patch)
tree8779a7c778b70ae585fc55e1f162fdf73290294e
parentef0313046b7a92b9249e3b75c90a221dc3958bba (diff)
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.
-rw-r--r--src/uchardet.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/uchardet.cpp b/src/uchardet.cpp
index f1951d1..46ee257 100644
--- a/src/uchardet.cpp
+++ b/src/uchardet.cpp
@@ -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);
}