Commit 23e5a763 authored by Nikias Bassen's avatar Nikias Bassen

plist_array_get_item_index(): return UINT_MAX instead of 0 when node can't be found

parent 08c6143b
...@@ -247,7 +247,7 @@ extern "C" ...@@ -247,7 +247,7 @@ extern "C"
* Get the index of an item. item must be a member of a #PLIST_ARRAY node. * Get the index of an item. item must be a member of a #PLIST_ARRAY node.
* *
* @param node the 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); uint32_t plist_array_get_item_index(plist_t node);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <plist/Array.h> #include <plist/Array.h>
#include <algorithm> #include <algorithm>
#include <limits.h>
namespace PList namespace PList
{ {
...@@ -118,6 +119,9 @@ void Array::Remove(Node* node) ...@@ -118,6 +119,9 @@ void Array::Remove(Node* node)
if (node) if (node)
{ {
uint32_t pos = plist_array_get_item_index(node->GetPlist()); uint32_t pos = plist_array_get_item_index(node->GetPlist());
if (pos == UINT_MAX) {
return;
}
plist_array_remove_item(_node, pos); plist_array_remove_item(_node, pos);
std::vector<Node*>::iterator it = _array.begin(); std::vector<Node*>::iterator it = _array.begin();
it += pos; it += pos;
......
...@@ -430,7 +430,7 @@ PLIST_API uint32_t plist_array_get_item_index(plist_t node) ...@@ -430,7 +430,7 @@ PLIST_API uint32_t plist_array_get_item_index(plist_t node)
{ {
return node_child_position(father, 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) static void _plist_array_post_insert(plist_t node, plist_t item, long n)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment