Fix infinite loop for objects that reference themselves.
[pdfium.git] / core / src / fxcrt / fx_xml_composer.cpp
index d68dd1f..ed233ff 100644 (file)
@@ -1,42 +1,41 @@
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "../../include/fxcrt/fx_xml.h"\r
-#include "xml_int.h"\r
-void FX_XML_SplitQualifiedName(FX_BSTR bsFullName, CFX_ByteStringC &bsSpace, CFX_ByteStringC &bsName)\r
-{\r
-    if (bsFullName.IsEmpty()) {\r
-        return;\r
-    }\r
-    FX_INT32 iStart = 0;\r
-    for (; iStart < bsFullName.GetLength(); iStart ++) {\r
-        if (bsFullName.GetAt(iStart) == ':') {\r
-            break;\r
-        }\r
-    }\r
-    if (iStart >= bsFullName.GetLength()) {\r
-        bsName = bsFullName;\r
-    } else {\r
-        bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart);\r
-        iStart ++;\r
-        bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart, bsFullName.GetLength() - iStart);\r
-    }\r
-}\r
-void CXML_Element::SetTag(FX_BSTR qSpace, FX_BSTR tagname)\r
-{\r
-    IFX_Allocator* pAllocator = m_Children.m_pAllocator;\r
-    m_QSpaceName.Set(qSpace, pAllocator);\r
-    m_TagName.Set(tagname, pAllocator);\r
-}\r
-void CXML_Element::SetTag(FX_BSTR qTagName)\r
-{\r
-    ASSERT(!qTagName.IsEmpty());\r
-    IFX_Allocator* pAllocator = m_Children.m_pAllocator;\r
-    CFX_ByteStringC bsSpace, bsName;\r
-    FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName);\r
-    m_QSpaceName.Set(bsSpace, pAllocator);\r
-    m_TagName.Set(bsName, pAllocator);\r
-}\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../include/fxcrt/fx_xml.h"
+#include "xml_int.h"
+void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
+                               CFX_ByteStringC& bsSpace,
+                               CFX_ByteStringC& bsName) {
+  if (bsFullName.IsEmpty()) {
+    return;
+  }
+  int32_t iStart = 0;
+  for (; iStart < bsFullName.GetLength(); iStart++) {
+    if (bsFullName.GetAt(iStart) == ':') {
+      break;
+    }
+  }
+  if (iStart >= bsFullName.GetLength()) {
+    bsName = bsFullName;
+  } else {
+    bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart);
+    iStart++;
+    bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart,
+                             bsFullName.GetLength() - iStart);
+  }
+}
+void CXML_Element::SetTag(const CFX_ByteStringC& qSpace,
+                          const CFX_ByteStringC& tagname) {
+  m_QSpaceName = qSpace;
+  m_TagName = tagname;
+}
+void CXML_Element::SetTag(const CFX_ByteStringC& qTagName) {
+  ASSERT(!qTagName.IsEmpty());
+  CFX_ByteStringC bsSpace, bsName;
+  FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName);
+  m_QSpaceName = bsSpace;
+  m_TagName = bsName;
+}