summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-08-30 01:03:44 +0200
committerGravatar Nikias Bassen2023-08-30 01:03:44 +0200
commitd45396aad911d496494a587bd2d3ef20c2e8a8d0 (patch)
tree0f73b93cdb03cef6353b2d9c40034fdf1d8b999e /src/plist.c
parent2d8d7ef272db06783989f77ba1ed80aa0f4d2dfd (diff)
downloadlibplist-d45396aad911d496494a587bd2d3ef20c2e8a8d0.tar.gz
libplist-d45396aad911d496494a587bd2d3ef20c2e8a8d0.tar.bz2
Prevent adding NULL items to array/dictionary nodes
Thanks to @tihmstar for pointing this out!
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/plist.c b/src/plist.c
index 19279ed..2f4990c 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -654,6 +654,9 @@ static void _plist_array_post_insert(plist_t node, plist_t item, long n)
654 654
655void plist_array_set_item(plist_t node, plist_t item, uint32_t n) 655void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
656{ 656{
657 if (!item) {
658 return;
659 }
657 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) 660 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX)
658 { 661 {
659 plist_t old_item = plist_array_get_item(node, n); 662 plist_t old_item = plist_array_get_item(node, n);
@@ -675,6 +678,9 @@ void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
675 678
676void plist_array_append_item(plist_t node, plist_t item) 679void plist_array_append_item(plist_t node, plist_t item)
677{ 680{
681 if (!item) {
682 return;
683 }
678 if (node && PLIST_ARRAY == plist_get_node_type(node)) 684 if (node && PLIST_ARRAY == plist_get_node_type(node))
679 { 685 {
680 node_attach((node_t)node, (node_t)item); 686 node_attach((node_t)node, (node_t)item);
@@ -684,6 +690,9 @@ void plist_array_append_item(plist_t node, plist_t item)
684 690
685void plist_array_insert_item(plist_t node, plist_t item, uint32_t n) 691void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
686{ 692{
693 if (!item) {
694 return;
695 }
687 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) 696 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX)
688 { 697 {
689 node_insert((node_t)node, n, (node_t)item); 698 node_insert((node_t)node, n, (node_t)item);
@@ -852,6 +861,9 @@ plist_t plist_dict_get_item(plist_t node, const char* key)
852 861
853void plist_dict_set_item(plist_t node, const char* key, plist_t item) 862void plist_dict_set_item(plist_t node, const char* key, plist_t item)
854{ 863{
864 if (!item) {
865 return;
866 }
855 if (node && PLIST_DICT == plist_get_node_type(node)) { 867 if (node && PLIST_DICT == plist_get_node_type(node)) {
856 plist_t old_item = plist_dict_get_item(node, key); 868 plist_t old_item = plist_dict_get_item(node, key);
857 plist_t key_node = NULL; 869 plist_t key_node = NULL;