pdr: pldm_is_current_parent_child(): Return false for invalid arguments
It can't be true that a node is a child of parent if either or both of
parent or node are NULL. Explicitly document this case.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ibabaff24e12f3b53f87ecbcb127d84ab1e7773ba
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4741f1c..954da3c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -57,6 +57,7 @@
13. pdr: pldm_entity_association_tree_visit(): Exit early on failure
14. pdr: pldm_entity_association_tree_destroy(): Exit early on bad argument
15. pdr: pldm_entity_get_num_children(): Return zero for invalid arguments
+16. pdr: pldm_is_current_parent_child(): Return false for invalid arguments
### Deprecated
diff --git a/include/libpldm/pdr.h b/include/libpldm/pdr.h
index 91b41de..25aa994 100644
--- a/include/libpldm/pdr.h
+++ b/include/libpldm/pdr.h
@@ -477,6 +477,9 @@
*
* @param[in] parent - opaque pointer acting as a handle to an entity parent
* @param[in] node - pointer to the node of the pldm entity
+ *
+ * @return True if the node is a child of parent, false otherwise, including if one or both of
+ * parent or node are NULL.
*/
bool pldm_is_current_parent_child(pldm_entity_node *parent, pldm_entity *node);
diff --git a/src/pdr.c b/src/pdr.c
index 7bf0f67..5cb72f6 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -771,6 +771,9 @@
{
assert(parent != NULL);
assert(node != NULL);
+ if (!parent || !node) {
+ return false;
+ }
pldm_entity_node *curr = parent->first_child;
while (curr != NULL) {