Hi Ryan,
I tried to reproduce a problem and could not. Perhaps if you can show the
calling code and the exact inputs to the function, that might help. Some
sort of stack overwrite sounds likely. Are you sure you're allocated the
incoming array properly and passing the appropriate length?
Dave
Ryan Sawatzky
<[EMAIL PROTECTED] To:
[email protected]
ox.com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: Seg Fault when
transcoding a XalanDOMString
03/31/2003 04:34
PM
Hi,
I am running into a strange problem trying to transcode a XalanDOMString
into a C-style character array. The program keeps seg faulting when I
try to delete the CharVectorType object returned by the
XalanDOMString::transcode() function. Here is the code for my function.
void ConvertDOMStringToCharArray( const XalanDOMString &string,
char *ch_array, int array_len )
{
/* Transcode the DOM String to a char vector */
CharVectorType *vector = new CharVectorType( string.transcode() );
if( vector == NULL )
return;
/* Grab the size of the element name, truncating it if necessary */
int size = vector->size();
if( size > array_len )
size = array_len;
/* Pull out the chars */
char *ch_ptr = ch_array;
for( int index = 0; index < size; index++ )
{
*ch_ptr = vector->at( index );
ch_ptr++;
}
/* Ensure the char array is NULL terminated */
ch_array[ array_len - 1 ] = NULL;
delete vector; <----- Seg Faults on this line
}
I am running this on Windows 2000, with SP 2, version 5.00.2195
Has anyone else ran into problems like this? Any and all help is
appreciated.
--Ryan