diff options
author | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-02-09 22:53:20 +0000 |
---|---|---|
committer | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-02-09 22:53:20 +0000 |
commit | 8b020e45f04d916217ac561eb103434f9e110ce8 (patch) | |
tree | ec21b3ccfa19a467d9495a51a127cdba66fdee9b /ACEXML | |
parent | ea6ef4e472a601ffdb3f32be347a85d2e733e5e7 (diff) | |
download | ATCD-8b020e45f04d916217ac561eb103434f9e110ce8.tar.gz |
ChangeLogTag: Thu Feb 9 22:49:18 UTC 2006 Krishnakumar B <kitty@nospam.invalid.domain>
Diffstat (limited to 'ACEXML')
-rw-r--r-- | ACEXML/ChangeLog | 16 | ||||
-rw-r--r-- | ACEXML/common/NamespaceSupport.cpp | 87 | ||||
-rw-r--r-- | ACEXML/common/NamespaceSupport.h | 8 | ||||
-rw-r--r-- | ACEXML/parser/parser/Parser.cpp | 20 | ||||
-rw-r--r-- | ACEXML/parser/parser/Parser.h | 9 |
5 files changed, 71 insertions, 69 deletions
diff --git a/ACEXML/ChangeLog b/ACEXML/ChangeLog index 29ca96b51ee..0ae649c3624 100644 --- a/ACEXML/ChangeLog +++ b/ACEXML/ChangeLog @@ -1,3 +1,19 @@ +Thu Feb 9 22:49:18 UTC 2006 Krishnakumar B <kitty@nospam.invalid.domain> + + * common/NamespaceSupport.h: + * common/NamespaceSupport.cpp: Use a normal ACE_Unbounded_Stack + instead of yet another custom stack. + + * parser/parser/Parser.h: + * parser/parser/Parser.cpp: + + Fixed a mismatched push/pop of the namespace context due to + popping namespace contexts without matching the end of the + element that caused a push. This resulted in more pops that + push and corrupting the memory. Also fixed an indirection into + a pointer that might have been corrupt when calling + startNamespacePrefix(). + Tue Jan 24 23:09:08 UTC 2006 Krishnakumar B <kitty@nospam.invalid.domain> * apps/svcconf/Svcconf.cpp: diff --git a/ACEXML/common/NamespaceSupport.cpp b/ACEXML/common/NamespaceSupport.cpp index 2f99ba13495..29c9a9315a7 100644 --- a/ACEXML/common/NamespaceSupport.cpp +++ b/ACEXML/common/NamespaceSupport.cpp @@ -15,7 +15,6 @@ static const ACEXML_Char ACEXML_XMLNS_URI_name[] = ACE_TEXT ("http://www.w3.org/ const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name; ACEXML_Namespace_Context_Stack::ACEXML_Namespace_Context_Stack (void) - : head_ (0) { } @@ -27,31 +26,54 @@ ACEXML_Namespace_Context_Stack::~ACEXML_Namespace_Context_Stack (void) int ACEXML_Namespace_Context_Stack::push (ACEXML_NS_CONTEXT *nsc) { - struct NS_Node_T *temp = 0; - ACE_NEW_RETURN (temp, NS_Node_T, -1); - - temp->item_ = nsc; - temp->next_ = this->head_; - - this->head_ = temp; - return 0; + return (this->stack_.push (nsc) < 0); } ACEXML_NS_CONTEXT * ACEXML_Namespace_Context_Stack::pop (void) { - if (this->head_ != 0) - { - struct NS_Node_T *temp = this->head_; - this->head_ = temp->next_; + if (this->stack_.size() <= 0) + return 0; - ACEXML_NS_CONTEXT* retv = temp->item_; - delete temp; - return retv; + ACEXML_NS_CONTEXT* temp = 0; + int retval = this->stack_.pop (temp); + if (retval != 0) + { + ACE_ERROR ((LM_ERROR, "Unable to pop Namespace context from stack\n")); + return 0; } + return temp; +} + +int +ACEXML_NamespaceSupport::popContext (void) +{ + delete this->effective_context_; + + if ((this->effective_context_ = this->ns_stack_.pop ()) == 0) + return -1; return 0; } +int +ACEXML_NamespaceSupport::pushContext (void) +{ + ACEXML_NS_CONTEXT *temp = this->effective_context_; + ACE_NEW_RETURN (this->effective_context_, + ACEXML_NS_CONTEXT (), + -1); + + // @@ Copy everything from the old context to the new one. + ACEXML_NS_CONTEXT_ENTRY *entry; + + for (ACEXML_NS_CONTEXT_ITER iter (*temp); + iter.next (entry) != 0; + iter.advance ()) + this->effective_context_->bind (entry->ext_id_, + entry->int_id_); + this->ns_stack_.push (temp); + return 0; +} ACEXML_NamespaceSupport::ACEXML_NamespaceSupport (void) : ns_stack_ (), @@ -175,37 +197,6 @@ ACEXML_NamespaceSupport::getURI (const ACEXML_Char *prefix) const } int -ACEXML_NamespaceSupport::popContext (void) -{ - delete this->effective_context_; - - if ((this->effective_context_ = this->ns_stack_.pop ()) == 0) - return -1; - return 0; -} - -int -ACEXML_NamespaceSupport::pushContext (void) -{ - ACEXML_NS_CONTEXT *temp = this->effective_context_; - ACE_NEW_RETURN (this->effective_context_, - ACEXML_NS_CONTEXT (), - -1); - - // @@ Copy everything from the old context to the new one. - ACEXML_NS_CONTEXT_ENTRY *entry; - - for (ACEXML_NS_CONTEXT_ITER iter (*temp); - iter.next (entry) != 0; - iter.advance ()) - this->effective_context_->bind (entry->ext_id_, - entry->int_id_); - this->ns_stack_.push (temp); - return 0; -} - - -int ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName, const ACEXML_Char *&uri, const ACEXML_Char *&name, @@ -220,7 +211,7 @@ ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName, break; } - ACEXML_String prefix; + ACEXML_String prefix ("",0,0); if (len == -1) name = qName; else diff --git a/ACEXML/common/NamespaceSupport.h b/ACEXML/common/NamespaceSupport.h index 4299b57ddcf..d81f9303d70 100644 --- a/ACEXML/common/NamespaceSupport.h +++ b/ACEXML/common/NamespaceSupport.h @@ -76,13 +76,7 @@ public: private: /// Internal stack structure to hold namespace context. - struct NS_Node_T { - ACEXML_NS_CONTEXT *item_; - struct NS_Node_T *next_; - }; - - /// Anchor point for head of stack. - NS_Node_T *head_; + ACE_Unbounded_Stack<ACEXML_NS_CONTEXT*> stack_; }; /** diff --git a/ACEXML/parser/parser/Parser.cpp b/ACEXML/parser/parser/Parser.cpp index 5989bd14de9..c9cc164c1cf 100644 --- a/ACEXML/parser/parser/Parser.cpp +++ b/ACEXML/parser/parser/Parser.cpp @@ -868,7 +868,7 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) this->xml_namespace_.processName(startname, ns_uri, ns_lname, 0); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), - ns_uri, ns_lname, 1 + ns_uri, 1 ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->content_handler_->startElement(ns_uri, ns_lname, @@ -879,7 +879,7 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), - ns_uri, ns_lname, 0 + ns_uri, 0 ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; if (ns_flag) @@ -892,7 +892,7 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) this->xml_namespace_.processName (startname, ns_uri, ns_lname, 0); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), - ns_uri, ns_lname, 1 + ns_uri, 1 ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->content_handler_->startElement(ns_uri, ns_lname, startname, @@ -982,15 +982,15 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) break; } } - if (this->parse_content (startname, ns_uri, ns_lname + if (this->parse_content (startname, ns_uri, ns_lname, ns_flag ACEXML_ENV_ARG_PARAMETER) != 0) return; } int ACEXML_Parser::parse_content (const ACEXML_Char* startname, - const ACEXML_Char* ns_uri, - const ACEXML_Char* ns_lname ACEXML_ENV_ARG_DECL) + const ACEXML_Char*& ns_uri, + const ACEXML_Char*& ns_lname, int ns_flag ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)) { ACEXML_Char *cdata; @@ -1076,14 +1076,17 @@ ACEXML_Parser::parse_content (const ACEXML_Char* startname, ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK_RETURN (-1); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), - ns_uri, ns_lname, 0 + ns_uri, 0 ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK_RETURN (-1); + if (this->namespaces_ && ns_flag) + { if (this->nested_namespace_ >= 1) { this->xml_namespace_.popContext (); this->nested_namespace_--; } + } return 0; } default: // a new nested element? @@ -2900,13 +2903,12 @@ ACEXML_Parser::parse_sddecl (ACEXML_Char*& str) void ACEXML_Parser::prefix_mapping (const ACEXML_Char* prefix, const ACEXML_Char* uri, - const ACEXML_Char* name, int start ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)) { if (this->namespaces_) { - const ACEXML_Char* temp = (name == 0) ? empty_string : prefix; + const ACEXML_Char* temp = (prefix == 0) ? empty_string : prefix; if (start) { this->content_handler_->startPrefixMapping (temp, uri ACEXML_ENV_ARG_PARAMETER); diff --git a/ACEXML/parser/parser/Parser.h b/ACEXML/parser/parser/Parser.h index 69fc7ec21a9..0fbbcb31fc6 100644 --- a/ACEXML/parser/parser/Parser.h +++ b/ACEXML/parser/parser/Parser.h @@ -215,8 +215,8 @@ protected: * Parse a content declaration. * */ - int parse_content (const ACEXML_Char* startname, const ACEXML_Char* ns_uri, - const ACEXML_Char* ns_lname + int parse_content (const ACEXML_Char* startname, const ACEXML_Char*& ns_uri, + const ACEXML_Char*& ns_lname, int ns_flag ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)); @@ -692,9 +692,8 @@ private: * @param start 1 => startPrefixMapping 0 => endPrefixMapping */ void prefix_mapping (const ACEXML_Char* prefix, - const ACEXML_Char* uri, - const ACEXML_Char* name, - int start ACEXML_ENV_ARG_DECL) + const ACEXML_Char* uri, + int start ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)); /** * Parse a keyword. |