PR# 14495 Incorrect omparison `num - cap <= 0' in run_idr.c
Problem Report Summary
Submitter: prestoat2000
Category: Runtime
Priority: Low
Date: 2008/06/19
Class: Bug
Severity: Non-critical
Number: 14495
Release: 6.2.73895
Confidential: No
Status: Closed
Responsible:
Environment: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.8.1.13) Gecko/20080328 Firefox/2.0.0.13
Solaris 10 on SPARC
Synopsis: Incorrect omparison `num - cap <= 0' in run_idr.c
Description
Based on warnings from lint and a small test program, it appears that every check in run_idr.c that looks like if ((num - cap) <= 0) is incorrect, because `num' and `cap' are both of type size_t, which is an unsigned type. The comparison will only ever be true if num == cap, which is unlikely in most cases. I confirmed this with the attached C test program. These 8 comparisons should be rewritten if (num <= cap) Before doing this, you should check the statements in the "if" branch, since they may never have been executed and so might have bugs. The bug doesn't look too harmful, except for a very small amount of wasted CPU.
To Reproduce
Problem Report Interactions
It is now fixed in rev#78021. The code was previously used extensively before that change from `int' to `size_t' in 2004 for supporting 64-bit platforms.