Skip to content

Fix memory leaks in validate_function.c - #14

Draft
matapatos wants to merge 1 commit into
mainfrom
vibe/fix-memory-leaks-validate-function-a54fe0
Draft

Fix memory leaks in validate_function.c#14
matapatos wants to merge 1 commit into
mainfrom
vibe/fix-memory-leaks-validate-function-a54fe0

Conversation

@matapatos

Copy link
Copy Markdown
Contributor

Fix memory leaks in validate_function.c

Changes

  • Track field_name ownership with field_name_owned flag to prevent double-free and memory leaks
  • Release field_name consistently in all error paths (exception handling, stop_at_first_error, missing fields)
  • Fix add_field_error to use ZVAL_STRINGL instead of ZVAL_STRING + zval_ptr_dtor (redundant since hash add does its own refcounting)
  • Ensure errors array is always cleaned up on all exception paths
  • Add continue statement after handling missing field_value to prevent fallthrough

Impact

  • Prevents memory leaks when validation fails
  • Improves code consistency and maintainability
  • No functional changes to validation logic

Closes #1

- Track field_name ownership with field_name_owned flag
- Release field_name consistently in all error paths
- Fix add_field_error to use ZVAL_STRINGL and remove redundant dtor
- Ensure errors array is always cleaned up on exception paths
- Add continue statement after handling missing field_value

Closes #1

Co-authored-by: matapatos <matapatos@users.noreply.github.com>
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.

2 participants