You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Zdenek Nemec <ze...@mapfactor.com> on 2002/11/27 13:16:24 UTC

Re: transcode - old pain (deleting transcoded string) SOLVED

i 've realized that problem could be in buffer size in bool
XMLString::copyNString ( XMLCh *const target, const XMLCh *const src, const
unsigned int maxChars )  in doc is noted that budffer size should be atLeast
(?!) +1 to maxChars  - so i guess that terminator is placed by copyNString
at the maxChars+1 in this case which is very confusing ( in compare to
'standart' strncpy() )

i also suggest to place in doc note that XMLString::stringLen() returns
value __excluding__  terminator

zdenek


----- Original Message -----
From: "Zdenek Nemec" <ze...@mapfactor.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, November 27, 2002 9:27 AM
Subject: transcode - old pain (deleting transcoded string)


> dear list,
> i found myself stuck again in XMLString::transcode( ),
>
> **after** following function  (ie. in strX  destructor ( deleting
transcoded
> string)  )
> i'll get  ( in VC7 on w2k box )  message:
>
>
> Unhandled exception at 0x1020a1fd (msvcr70d.dll)
> and break at dbgheap.c  line 1154
>
> please note i am **sure** i am using all my projects with Multi-threaded
> debug DLL
> (/MDd) same as project XercesLib -which created my xerces***.dll ( i have
> checked release/debug (aka /MD vs. /MDd ) too )
>
> any hint?
> has this something to do with bug #11915
>
> thank you in advance
>
> zdenek
>
>
>
> --example 'problem' func--
> void myFunc( const XMLCh* value ) {
>     strX tmp( value );
> } // here the 'crash'
>
> --my strX class--
> class strX {
> public:
>     strX( const XMLCh* const toTranscode ) {
>         if(!toTranscode) { _localForm=0; return; }
>         _size=XMLString::stringLen( toTranscode );
>         _localForm=new char[_size+1];
>         XMLString::transcode( toTranscode, _localForm, _size+1 );
>     }
>     ~strX() { delete[] _localForm; }
>     const char* localForm() const { return _localForm; }
> private:
>     char* _localForm;
>     unsigned _size;
> };
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org