From: Florian Forster Date: Mon, 15 May 2017 12:40:26 +0000 (+0200) Subject: curl_json plugin: Fix array index and key handling. X-Git-Tag: collectd-5.7.2~2^2~3 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=8a2be9037587c1b80a00ddb1d7d396d1d48ec37d;hp=8a2be9037587c1b80a00ddb1d7d396d1d48ec37d;p=collectd.git curl_json plugin: Fix array index and key handling. Previously, the "key" was loaded by calling cj_cb_map_key() from cj_cb_inc_array_index(). That means that the key for the previous element was loaded as the array index was updated for the next element, resulting in an off-by-one error. Also the key was not unset in time, resulting in two metrics with the same identifier being created. This patch fixes this with the following changes: * cj_advance_array() (nee cj_cb_inc_array_index()) now loads the key for the new index position instead of the previous one. * The initial "0" key is loaded from cj_cb_start_array(). * cj_advance_array() always updates the key. The "update_key" argument has been removed. * Refactoring: key loading has been moved out of cj_cb_map_key() and into its own function, cj_load_key(). Unit tests are in a separate commit for easier cherry-picking. Fixes: #2266 ---