From feb0bcd102ff0abc34ffa04e8cabf26706ffdb38 Mon Sep 17 00:00:00 2001 From: liujianfengv Date: Sat, 26 Jun 2021 11:43:42 +0800 Subject: cpp: Array: Make sure the array passed to array_fill ist passed by reference When creating a new Array object, for example through PList::Node::FromPlist(plist_t node), the array_fill function is called from Array() constructor in line 51. It seems that the intended way of calling array_fill() is to pass the _array object by reference, however it is actually passed by value. Thus the changes to the array object made by array_fill() are discarded when the function returns. This commit passes the _array by reference so we keep the changes. --- src/Array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Array.cpp b/src/Array.cpp index 65ffaa7..23f9922 100644 --- a/src/Array.cpp +++ b/src/Array.cpp @@ -32,7 +32,7 @@ Array::Array(Node* parent) : Structure(PLIST_ARRAY, parent) _array.clear(); } -static void array_fill(Array *_this, std::vector array, plist_t node) +static void array_fill(Array *_this, std::vector &array, plist_t node) { plist_array_iter iter = NULL; plist_array_new_iter(node, &iter); -- cgit v1.1-32-gdbae