diff options
-rw-r--r-- | include/plist/plist.h | 2 | ||||
-rw-r--r-- | src/Array.cpp | 4 | ||||
-rw-r--r-- | src/plist.c | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index 263efa8..63e9d84 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -247,7 +247,7 @@ extern "C" * Get the index of an item. item must be a member of a #PLIST_ARRAY node. * * @param node the node - * @return the node index + * @return the node index or UINT_MAX if node index can't be determined */ uint32_t plist_array_get_item_index(plist_t node); diff --git a/src/Array.cpp b/src/Array.cpp index a511841..d5d9d7c 100644 --- a/src/Array.cpp +++ b/src/Array.cpp @@ -22,6 +22,7 @@ #include <plist/Array.h> #include <algorithm> +#include <limits.h> namespace PList { @@ -118,6 +119,9 @@ void Array::Remove(Node* node) if (node) { uint32_t pos = plist_array_get_item_index(node->GetPlist()); + if (pos == UINT_MAX) { + return; + } plist_array_remove_item(_node, pos); std::vector<Node*>::iterator it = _array.begin(); it += pos; diff --git a/src/plist.c b/src/plist.c index f22a8a0..3ffedc4 100644 --- a/src/plist.c +++ b/src/plist.c @@ -430,7 +430,7 @@ PLIST_API uint32_t plist_array_get_item_index(plist_t node) { return node_child_position(father, node); } - return 0; + return UINT_MAX; } static void _plist_array_post_insert(plist_t node, plist_t item, long n) |