Tests crash due to incorrect invokation of constructor method of CBufDescriptor

VERIFIED FIXED

Status

P3
normal
VERIFIED FIXED
18 years ago
8 years ago

People

(Reporter: rpallath, Assigned: rpallath)

Tracking

({crash})

Trunk
Sun
Solaris
crash

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

18 years ago
The oji API tests fail on Solaris when returning the Test status.
(see mozilla/module/oji/tests/src/include)
The bug is in ojiapitests.h

In the method TestResult

   CBufDescriptor class has two constructors (currently we use the first one):
   	CBufDescriptor::CBufDescriptor(char* aString, ...) {
   		...
		mIsConst=PR_FALSE;
		...
   	}
   	CBufDescriptor::CBufDescriptor(const char* aString, ...) {
   		...
   		mIsConst=PR_TRUE;
   		...
   	}

   Then we create nsString object using nsAutoString(const CBufDescriptor&
aBuffer)
   constructor. In the body of this constructor there are the following lines:
   	nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() {
	  ...
	    if(!aBuffer.mIsConst)
		    AddNullTerminator(*this);
	}
   where AddNullTerminator(...) method looks like that:
   	inline void AddNullTerminator(nsStr& aDest) {
	  if(eTwoByte==aDest.mCharSize) 
	    aDest.mUStr[aDest.mLength]=0;
	  else aDest.mStr[aDest.mLength]=0;
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	}

   But usually we allocate as much memory as we really need for the string and
   so attempt to write to the aDest.mStr[aDest.mLength] results in segmentation
   violation error (index shouldn't be more than aDest.mLength-1).

the fix reqd. is to invoke    CBufDescriptor::CBufDescriptor(const char*
aString, ...) constructor.
(Assignee)

Comment 1

18 years ago
Assigning to myself (in charge of OJI Tests).
Assignee: drapeau → rpallath

Comment 2

18 years ago
*spam*

adding crash keyword...
Keywords: crash
(Assignee)

Comment 3

18 years ago
Created attachment 18567 [details] [diff] [review]
cvs diff -u ojiapitests.h
(Assignee)

Comment 4

18 years ago
These are OJI test cases and they are not part of the  build process.

I will be checking changes into the trunk (no branch). I do have the fix
I have attached the diff.
(currently being reviewed by ed.burnn@eng.sun.com)

(Assignee)

Updated

18 years ago
Status: NEW → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
(Assignee)

Comment 5

18 years ago
Fixed.
Validated it with FCS bits of  NS6 on Solaris with FCS version of JRe 1.3.0_01.
(Assignee)

Comment 6

18 years ago
Verfied.
Status: RESOLVED → VERIFIED

Updated

8 years ago
Component: Java: OJI → Java: OJI
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.