From 23e5a7636bba1565d000adcd4c3debc0788398c5 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 19 May 2019 00:27:43 +0200 Subject: plist_array_get_item_index(): return UINT_MAX instead of 0 when node can't be found --- src/Array.cpp | 4 ++++ src/plist.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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 #include +#include 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::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) -- cgit v1.1-32-gdbae