Closed Bug 8125 Opened 25 years ago Closed 25 years ago

nsString2::ToInteger fails to set error code

Categories

(Core :: Layout, defect, P3)

All
Mac System 8.5
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: sfraser_bugs, Assigned: rickg)

Details

Attachments

(1 file)

On investigating the window sizing problem in apprunning, I notice that
PRInt32 nsString2::ToInteger(PRInt32* anErrorCode) fails to set the error
code in some cases.

The implemenation looks like:
{
  nsAutoString2 theString(*this,eOneByte);
  PRUint32  theRadix=10;
  PRInt32   result=GetNumericSubstring(theString,theRadix);

  if(NS_OK==result){
    result=_ToInteger(theString,anErrorCode,theRadix);
  }
  return result;
}

If called on an empty string, GetNumericSubstring() returns an error
code, but this is never set in *anErrorCode before return. So in this
situation, *anErrorCode is left unset, and the function returns a large
negative value.
Attached patch Proposed fixSplinter Review
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Added more error reporting to this method. In particular, if you hand in a plain
text string, or an empty string you'll get an error code.
Rick-  I would verify this fix in the latest build. Can I verify this with a test
case ?
Status: RESOLVED → VERIFIED
Marking verified fixed.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: