You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by Joe Polastre <jp...@locus.apache.org> on 2000/07/07 02:12:52 UTC

cvs commit: xml-xerces/c/src/com IXMLDOMCharacterDataImpl.h

jpolast     00/07/06 17:12:51

  Modified:    c/src/com IXMLDOMCharacterDataImpl.h
  Log:
  bug fixes for non-null terminated strings
  
  Revision  Changes    Path
  1.3       +18 -3     xml-xerces/c/src/com/IXMLDOMCharacterDataImpl.h
  
  Index: IXMLDOMCharacterDataImpl.h
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/com/IXMLDOMCharacterDataImpl.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IXMLDOMCharacterDataImpl.h	2000/03/30 02:00:13	1.2
  +++ IXMLDOMCharacterDataImpl.h	2000/07/07 00:12:51	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: IXMLDOMCharacterDataImpl.h,v $
  + * Revision 1.3  2000/07/07 00:12:51  jpolast
  + * bug fixes for non-null terminated strings
  + *
    * Revision 1.2  2000/03/30 02:00:13  abagchi
    * Initial checkin of working code with Copyright Notice
    *
  @@ -70,6 +73,16 @@
   WORD wMinor = 0, class tihclass = CComTypeInfoHolder>
   class ATL_NO_VTABLE IXMLDOMCharacterDataImpl: public IXMLDOMNodeImpl<T,piid,plibid,wMajor,wMinor,tihclass>
   {
  +private:
  +	XMLCh* DOMStringToXMLCh(DOMString str)
  +	{
  +		XMLCh* cdata = new XMLCh[str.length()+1];
  +		for (unsigned int i=0; i < str.length(); i++)
  +			cdata[i] = str.charAt(i);
  +		cdata[str.length()] = 0;
  +		return cdata;
  +	}
  +
   public:
   
   	virtual DOM_CharacterData& get_DOM_CharacterData() = 0; 
  @@ -88,7 +101,8 @@
   	
   	try
   	{
  -		*pVal = SysAllocString(get_DOM_CharacterData().getData().rawBuffer());
  +		//*pVal = SysAllocString(get_DOM_CharacterData().getData().rawBuffer());
  +		*pVal = SysAllocString(DOMStringToXMLCh(get_DOM_CharacterData().getData()));
   	}
   	catch(...)
   	{
  @@ -148,7 +162,8 @@
   
   	try
   	{
  -		*data = SysAllocString(get_DOM_CharacterData().substringData(offset, count).rawBuffer());
  +		// need to copy the string to a new buffer since DOMString doesn't null terminate the substring.
  +		*data = SysAllocString(DOMStringToXMLCh(get_DOM_CharacterData().substringData(offset, count)));
   	}
   	catch(...)
   	{