Skip to content

Add defensive NULL pointer guards across public APIs and extend tests - #355

Closed
filtede98 wants to merge 1 commit into
yaml:masterfrom
filtede98:fix-null-guards
Closed

filtede98 wants to merge 1 commit into
yaml:masterfrom
filtede98:fix-null-guards

Conversation

@filtede98

Copy link
Copy Markdown

Summary of Changes

This patch improves API stability and robustness across libyaml public interfaces by adding defensive NULL pointer checks:

  • yaml_get_version: Allow callers to query only specific components (e.g., major, minor, or patch) by safely checking pointer arguments before writing.
  • Parser and Emitter Lifecycle: Add NULL pointer validations in initialization, deletion, stream setup, and configuration functions (yaml_parser_initialize, yaml_parser_delete, yaml_parser_set_*, yaml_emitter_initialize, yaml_emitter_delete, yaml_emitter_set_*).
  • Document and Event Management: Ensure functions handling event initialization/deletion and document creation/node addition safely guard against NULL parameters.
  • Engine Entrypoints: Add defensive NULL guards to yaml_parser_parse, yaml_parser_scan, yaml_emitter_emit, yaml_emitter_open, yaml_emitter_close, yaml_emitter_dump, and yaml_parser_load.
  • Tests: Extended tests/test-version.c with unit assertions validating NULL safety across the updated functions.

@filtede98

Copy link
Copy Markdown
Author

Closing this PR as it hasn't received feedback and the NULL guards are defensive only. Thanks for maintaining the project!

@filtede98 filtede98 closed this Oct 18, 2026
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.

1 participant