You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2001/02/14 15:44:12 UTC

cvs commit: xml-xerces/c/src/internal XMLReader.cpp

knoaman     01/02/14 06:44:12

  Modified:    c/src/internal XMLReader.cpp
  Log:
  Core when UTF-16 encoding Contradicts actual encoding - Fix by Mark Everline
  
  Problem: In any message when the Encoding controdicts the
  actuall encoding the the parser core dumps because the
  XMLReader::setEncoding(...) deletes the fEncodingStr before
  error check and leaving the variable in a invalid state.
  
  Revision  Changes    Path
  1.24      +25 -10    xml-xerces/c/src/internal/XMLReader.cpp
  
  Index: XMLReader.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/internal/XMLReader.cpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XMLReader.cpp	2000/10/18 00:21:07	1.23
  +++ XMLReader.cpp	2001/02/14 14:44:11	1.24
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLReader.cpp,v 1.23 2000/10/18 00:21:07 andyh Exp $
  + * $Id: XMLReader.cpp,v 1.24 2001/02/14 14:44:11 knoaman Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -1108,11 +1108,12 @@
           return true;
   
       // Clean up the old encoding string
  -    if (fEncodingStr)
  -    {
  -        delete [] fEncodingStr;
  -        fEncodingStr = 0;
  -    }
  +	// Do not delete until we know we have a good encoding
  +//	if (fEncodingStr)
  +//	{
  +//		delete [] fEncodingStr;
  +//		fEncodingStr = 0;
  +//	}
   
       //
       //  Try to map the string to one of our standard encodings. If its not
  @@ -1149,11 +1150,17 @@
   
               // Override with the original endian specific encoding
               newBaseEncoding = fEncoding;
  +
  +            if (fEncoding == XMLRecognizer::UTF_16L) {
   
  -            if (fEncoding == XMLRecognizer::UTF_16L)
  +				delete [] fEncodingStr;
                   fEncodingStr = XMLString::replicate(XMLUni::fgUTF16LEncodingString);
  -            else
  +			}
  +            else {
  +
  +				delete [] fEncodingStr;
                   fEncodingStr = XMLString::replicate(XMLUni::fgUTF16BEncodingString);
  +			}
           }
            else if (!XMLString::compareIString(newEncoding, XMLUni::fgUCS4EncodingString)
                 ||  !XMLString::compareIString(newEncoding, XMLUni::fgUCS4EncodingString2)
  @@ -1167,21 +1174,29 @@
   
               // Override with the original endian specific encoding
               newBaseEncoding = fEncoding;
  +
  +            if (fEncoding == XMLRecognizer::UCS_4L) {
   
  -            if (fEncoding == XMLRecognizer::UCS_4L)
  +                delete [] fEncodingStr;
                   fEncodingStr = XMLString::replicate(XMLUni::fgUCS4LEncodingString);
  -            else
  +			}
  +            else {
  +
  +                delete [] fEncodingStr;
                   fEncodingStr = XMLString::replicate(XMLUni::fgUCS4BEncodingString);
  +			}
           }
            else
           {
               // None of those special cases, so just replicate the new name
  +            delete [] fEncodingStr;
               fEncodingStr = XMLString::replicate(newEncoding);
           }
       }
        else
       {
           // Store the new encoding string since it is just an intrinsic
  +        delete [] fEncodingStr;
           fEncodingStr = XMLString::replicate(newEncoding);
       }