Skip to content

[#701] Clear the iterator when pgexporter_json_iterator_create fails - #702

Open
LoayTarek5 wants to merge 1 commit into
pgexporter:mainfrom
LoayTarek5:fix-json-iterator-701
Open

LoayTarek5 wants to merge 1 commit into
pgexporter:mainfrom
LoayTarek5:fix-json-iterator-701

Conversation

@LoayTarek5

Copy link
Copy Markdown

Fix #701

cross-port of pgmoneta/pgmoneta#1416, pgexporter_json_iterator_create() returned 1 without setting *iter, so a caller could be left with a stale or uninitialized iterator, so now *iter is set to NULL first, and next() and destroy() already handle NULL

also added test_json_iterator_failure, and added myself to AUTHORS since this is my first pr here

@Pranav-error Pranav-error left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the json.c change the new test hits a heap-use-after-free under ASan (iter still points at the destroyed iterator); with it, it passes, and the json tests pass. Same as pgmoneta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pgexporter_json_iterator_create leaves the iterator unset when it fails

2 participants