DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9263>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9263

At char *DOMString::transcode() - null terminations problems

           Summary: At char *DOMString::transcode() - null terminations
                    problems
           Product: Xerces-C++
           Version: 1.7.0
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I'm transcoding strings in "UTF8" encoding.
There are 2 bugs:
1. The first bug happens when transcoding strings with unicode characters which 
their code takes 2 bytes length (or more), therefore the charsNeeded IS NOT 
fHandle->fLength!
Here is what happens - (see the remarks)
----------------------------------------------------------------------
    const unsigned int charsNeeded = fHandle->fLength;   -------->WRONG LENGHT
    char* retP = new char[charsNeeded + 1];

    if (!getDomConverter()->transcode(srcP, retP, charsNeeded)) --->return false
    {
        delete [] retP;
        const unsigned int charsNeeded2 = getDomConverter()->calcRequiredSize
(srcP);        ----------->CALC THE RIGHT LENGTH
        retP = new char[charsNeeded2 + 1];
        if (!getDomConverter()->transcode(srcP, retP, charsNeeded2))---->OK
        {
            // <TBD> We should throw something here?
        }
    }
    delete [] allocatedBuf;   // which will be null if we didn't allocate one.

    // Cap it off and return it
    retP[charsNeeded] = 0; --------> HERE IS THE PROBLEM: The null termination
is not in the right index. it should be the updated retP length which is now 
charsNeeded2  - it ruin the string!
-----------------------------------------------------------------------------

2. The second bug, occur when creating DOMString by char* (with the same 
unicode characters). The DOMString is not null terminated. I can't say exactly 
what happens there but my guess is that it's again due to wrong calculation of 
the buffer allocation size.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to