Closed Bug 228542 Opened 21 years ago Closed 21 years ago

Divide by zero bug in Universal charset detecter

Categories

(Core :: Internationalization, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: vladimir, Assigned: vladimir)

References

Details

(Keywords: fixed-aviary1.0, fixed1.7.5)

Attachments

(2 files)

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Opera 7.23 [en] Build Identifier: When text chunk have no latin chars we get divide by zero Error In nsLatin1Prober.cpp Line 193 confidence = mFreqCounter[3]*1.0f / total; confidence -= mFreqCounter[1]*20.0f/total; Must be replaced with if(!total) confidence = 0.0f; else{ confidence = mFreqCounter[3]*1.0f / total; confidence -= mFreqCounter[1]*20.0f/total; } Reproducible: Always Steps to Reproduce: 1. 2. 3.
Is there a reproducible crash associated with this, or did you find the bug by code inspection? I ask only out of curiosity, and I agree that we should fix this anyway.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Yes and Yes. I found it while debug universal detector as DLL on little amount of text. Two bugs (In reply to comment #1) > Is there a reproducible crash associated with this, or did you find the bug by > code inspection? I ask only out of curiosity, and I agree that we should fix > this anyway. Yes and Yes. I found it while debug universal detector as DLL on little amount of text. Two bugs 228545 and 228542 are interrelated.
Attached patch patchSplinter Review
Attachment #151519 - Flags: review?(smontagu)
Due to bug 228542 if we have no english chars in file (text chuck) total will be equal to 0 and confidence = mFreqCounter[3]*1.0f / total; will crash detector or fill confidence with NaN
Attachment #151519 - Flags: superreview?(roc)
Comment on attachment 151519 [details] [diff] [review] patch No need for a new patch this time, but in future please make your patches with diff -pu9 r=smontagu
Attachment #151519 - Flags: review?(smontagu) → review+
Assignee: smontagu → vladimir
Attachment #151519 - Flags: superreview?(roc) → superreview+
Depends on: 228545
Attachment #151519 - Flags: approval1.7.1?
Comment on attachment 151519 [details] [diff] [review] patch a=mkaply for 1.7.1 When this is checked in, please use consistent bracing on the if statement. thanks
Attachment #151519 - Flags: approval1.7.1? → approval1.7.1+
mozilla/extensions/universalchardet/src/nsLatin1Prober.cpp 1.5
AVIARY_1_0_20040515_BRANCH does not checkin yet.
mozilla/extensions/universalchardet/src/nsLatin1Prober.cpp 1.3.50.1
Keywords: fixed1.7.1
The patch appears to have been checked in, but this bug is still not marked FIXED -- any reason why? Timeless?
Thanx for mention.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: