summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_node_unittest.cpp16
2 files changed, 15 insertions, 15 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index a895b855d0..83da3e76df 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1112,8 +1112,10 @@ CXFA_Node* CXFA_Node::GetChildInternal(size_t index,
}
void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
- ASSERT(pNode);
- ASSERT(!pNode->parent_);
+ if (!pNode || pNode->parent_ != nullptr) {
+ PDFIUM_IMMEDIATE_CRASH();
+ }
+
pNode->parent_ = this;
pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren);
@@ -1173,8 +1175,7 @@ void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
void CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) {
if (pBeforeNode && pBeforeNode->parent_ != this) {
- NOTREACHED();
- return;
+ PDFIUM_IMMEDIATE_CRASH();
}
int32_t index = -1;
@@ -1194,8 +1195,9 @@ void CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) {
}
void CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) {
- ASSERT(pNode);
- ASSERT(pNode->parent_ == this);
+ if (!pNode || pNode->parent_ != this) {
+ PDFIUM_IMMEDIATE_CRASH();
+ }
pNode->SetFlag(XFA_NodeFlag_HasRemovedChildren, true);
diff --git a/xfa/fxfa/parser/cxfa_node_unittest.cpp b/xfa/fxfa/parser/cxfa_node_unittest.cpp
index 9afc0f254f..7c35e5d989 100644
--- a/xfa/fxfa/parser/cxfa_node_unittest.cpp
+++ b/xfa/fxfa/parser/cxfa_node_unittest.cpp
@@ -360,7 +360,6 @@ TEST_F(CXFANodeTest, RemoveChild) {
EXPECT_EQ(nullptr, child1->GetPrevSibling());
}
-#ifndef NDEBUG
TEST_F(CXFANodeTest, InsertChildWithParent) {
CXFA_Node* child0 =
GetDoc()->CreateNode(XFA_PacketType::Form, XFA_Element::Ui);
@@ -368,15 +367,15 @@ TEST_F(CXFANodeTest, InsertChildWithParent) {
GetDoc()->CreateNode(XFA_PacketType::Form, XFA_Element::Ui);
child0->InsertChild(-1, child1);
- EXPECT_DEATH(GetNode()->InsertChild(0, child1), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->InsertChild(0, child1), "");
}
TEST_F(CXFANodeTest, InsertNullChild) {
- EXPECT_DEATH(GetNode()->InsertChild(0, nullptr), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->InsertChild(0, nullptr), "");
}
TEST_F(CXFANodeTest, InsertBeforeWithNullChild) {
- EXPECT_DEATH(GetNode()->InsertChild(nullptr, nullptr), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->InsertChild(nullptr, nullptr), "");
}
TEST_F(CXFANodeTest, InsertBeforeWithBeforeInAnotherParent) {
@@ -390,7 +389,7 @@ TEST_F(CXFANodeTest, InsertBeforeWithBeforeInAnotherParent) {
CXFA_Node* child =
GetDoc()->CreateNode(XFA_PacketType::Form, XFA_Element::Ui);
- EXPECT_DEATH(GetNode()->InsertChild(child, child1), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->InsertChild(child, child1), "");
}
TEST_F(CXFANodeTest, InsertBeforeWithNodeInAnotherParent) {
@@ -402,11 +401,11 @@ TEST_F(CXFANodeTest, InsertBeforeWithNodeInAnotherParent) {
GetDoc()->CreateNode(XFA_PacketType::Form, XFA_Element::Ui);
child0->InsertChild(-1, child1);
- EXPECT_DEATH(GetNode()->InsertChild(child1, nullptr), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->InsertChild(child1, nullptr), "");
}
TEST_F(CXFANodeTest, RemoveChildNullptr) {
- EXPECT_DEATH(GetNode()->RemoveChild(nullptr, false), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->RemoveChild(nullptr, false), "");
}
TEST_F(CXFANodeTest, RemoveChildAnotherParent) {
@@ -418,6 +417,5 @@ TEST_F(CXFANodeTest, RemoveChildAnotherParent) {
GetDoc()->CreateNode(XFA_PacketType::Form, XFA_Element::Ui);
child0->InsertChild(-1, child1);
- EXPECT_DEATH(GetNode()->RemoveChild(child1, false), "");
+ EXPECT_DEATH_IF_SUPPORTED(GetNode()->RemoveChild(child1, false), "");
}
-#endif // NDEBUG