forked from collectd/collectd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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(). * The unit tests have been expanded to cover this case. Fixes: collectd#2266
- Loading branch information
Showing
2 changed files
with
119 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters