[jdom-interest] How to "crash" JDOM, part 1

trebor.a.rude at lmco.com trebor.a.rude at lmco.com
Thu Aug 31 11:34:09 PDT 2000


	The existing implementation of addContent() already checks if
isRootElement is true, and won't allow the add if it is (unfortunately, adds
via the PartialList check neither condition and may well be used to create
all sorts of messed up trees, gotta make sure that gets fixed once we decide
the extent of the fix needed), so it shouldn't be possible to add the root
node as a child of any other Element in the tree. So again it looks like all
that is needed is a quick check for self-reference to prevent loops. Any
other cases?

> -----Original Message-----
> From:	David W. Smiley [SMTP:dsmiley at mitre.org]
> Sent:	Thursday, August 31, 2000 12:14 PM
> To:	trebor.a.rude at lmco.com
> Cc:	jdom-interest at jdom.org
> Subject:	Re: [jdom-interest] How to "crash" JDOM, part 1
> 
> > After thinking about this a little more, I suspect we may
> > be making
> > things harder than they need to be. Given the existing constraint
> > that you
> > can't add an Element that already has a parent, I can't see any
> > way that
> > it's possible for an Element to have a pointer to any of its
> > ancestors in
> > its content list. The only degenerate case I can see is
> > "element.addContent(element)" on a newly created Element, which
> > can be
> > solved with a simple check for self-reference in addition to the
> > check for a
> > null parent. Did I miss a case?
> 
> 	Yes.  What if you have some big tree and you add the rootElement to
> one
> of the leaves.  This is the other extreme of your self-reference
> example; your case is when the rootElement is the leaf.  This has
> nothing to do with whether docRootElement is true or false.
> 	BTW, to make getRootElement() faster, I'd do it with iteration, not
> recursion since it'll be faster; my example was just pseuodocode anyway.
> 
> -- David Smiley
> 



More information about the jdom-interest mailing list