RE: [xml] xmlCopyNode error
- From: martyn 2 russell bt com
- To: xml gnome org
- Subject: RE: [xml] xmlCopyNode error
- Date: Thu, 25 Apr 2002 09:56:07 +0100
Ok, I have figured out the dodgy roster problem (genuine mistake on my part
with buf sizes), however three things:
1st: If I use xmlUnlinkNode() and xmlFreeNode() I then have to set the node
(ctxt->myDoc->children) to NULL for the application to continue, else I get
the same xmlCopyNode error I originally reported.
2nd: If I use xmlFreeNodeList() instead of xmlFreeNode(), I need NOT set the
node to NULL to keep the application from crashing.
3rd: The documentation doesn't state whether the node is set to NULL when
calling xmlFreeNode() or xmlFreeNodeList(), Does it?
In the first case, should I have to set my node to NULL?
Regards,
Martyn
-----Original Message-----
From: martyn 2 russell bt com [mailto:martyn 2 russell bt com]
Sent: Wednesday, April 24, 2002 7:05 PM
To: xml gnome org
Subject: RE: [xml] xmlCopyNode error
To initiate the parser, i use the following function,
ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
Then when i receive information on the socket, I call the following
function:
xmlParseChunk(ctxt,buf,nBytes,0);
if(ctxt->myDoc->children != NULL)
{
xmlNodePtr myCopy = NULL;
myCopy = xmlCopyNode(ctxt->myDoc->children,1);
/* parse doc by type - i.e iq/message.... */
if(myCopy != NULL)
jb_ParseType(myCopy);
xmlUnlinkNode(ctxt->myDoc->children);
xmlFreeNode(ctxt->myDoc->children);
//ctxt->myDoc->children = NULL;
}
The funny thing is, that it's fine up to that xml input from jabber ("<iq
id='3' type='result'/>"), however, if I uncomment the line above
("//ctxt->myDoc->children = NULL;") I have no problem at that stage, instead
the input when i receive the roster is dodgy, which is really confusing
(below): And the print out of the contents is just blank spaces????
62 of 62 --> '
<iq id="4" type="get"><query xmlns="jabber:iq:roster"/></iq>
'
266 <-- '<iq id='4' type='result' from='russelm6 coyote/testclient'><query
xmlns='jabber:iq:roste
r'><item jid='cockersj coyote' subscription='both'>
<group>Work</group>
</item><item jid='bootonlj coyote' subscription='both'>
<group>Work</group>
< 4
°åÿ¿
********** start printing tree node:0x080a9c18 *********
-> name:'iq'
-> name:'query'
-> name:'item'
- content:'
'
-> name:'group'
- content:'Work'
- content:'
'
-> name:'item'
- content:'
'
-> name:'group'
- content:'Work'
- content:'
'
********** stop printing tree node:0x080a9c18 *********
Any ideas??
Regards,
Martyn
-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Wednesday, April 24, 2002 6:46 PM
To: martyn 2 russell bt com
Cc: xml gnome org
Subject: Re: [xml] xmlCopyNode error
On Wed, Apr 24, 2002 at 06:34:34PM +0100, martyn 2 russell bt com wrote:
I am trying to copy a node which has been parsed from a Jabber input
stream.
However when I do, the name is "" and the contents of the node I am trying
to copy is out of bounds? Why is this? This only happens for the input
"<iq
id='3' type='result'/>". I have managed to parse other bits and pieces
fine
hoh Jabber, nice ;-)
and not had this problem, can anyone help?
The gdb output is show below:
26 <-- '<iq id='3' type='result'/>'
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 18377)]
0x402f30d0 in xmlStrdup () from /usr/lib/libxml2.so.2
(gdb) up
#1 0x4030828e in xmlStaticCopyNode () from /usr/lib/libxml2.so.2
(gdb) up
#2 0x40308517 in xmlCopyNode () from /usr/lib/libxml2.so.2
(gdb) up
#3 0x080550ae in JB_ParseInput (buf=0xbfffe570 "<iq id='3'
type='result'/>",
nBytes=26) at ../jb_parse.c:165
(gdb) p (*ctxt->myDoc->children)
$1 = {_private = 0x80a9360, type = 134912736, name = 0x80a9ae0 "",
how did you got a chidl without name ???
children = 0x80aac08, last = 0x0, parent = 0x80aab28, next = 0x80a9398,
prev = 0x0, doc = 0x0, ns = 0x11,
content = 0x65707974 <Address 0x65707974 out of bounds>,
properties = 0x404e3600, nsDef = 0x0}
Seems there is something really strange with the way your parser
context is set up. I think I know what you're trying to do but without
knowing what are the parameters passed to xmlCopyNode() it's nearly
impossible to find out where is the trouble.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]