Skip to content

Fix memory leaks and secure reference resolution#44

Open
Alvi16 wants to merge 4 commits intokovzol:masterfrom
Alvi16:Alx
Open

Fix memory leaks and secure reference resolution#44
Alvi16 wants to merge 4 commits intokovzol:masterfrom
Alvi16:Alx

Conversation

@Alvi16
Copy link
Copy Markdown

@Alvi16 Alvi16 commented Mar 25, 2026

Proposed Changes

This modification addresses several critical issues in the reference resolution loop:

  • Crash Prevention (Null Pointer Dereference):
    The code now checks if cur_ref is NULL after the ls_nth call before accessing its members. This prevents a systematic crash if a reference is invalid.

  • Memory Leak Fixes:
    Previously, the function could return NULL prematurely without freeing the refs vector. I have added calls to destroy_str_vec(refs) before every error return path.

  • Improved Error Handling:
    Instead of a silent NULL return, the function now sets *ret_val to VALUE_TYPE_ERROR and returns an explicit, translatable error message via _().


Note: Tested with invalid references to confirm stability.

Alvi16 added 3 commits March 25, 2026 20:17
- Fix variable name typo in sen_data_evaluate() (line 337)
  Changed *ref_val to *ret_val to ensure correct error variable is set

- Fix NULL pointer dereference in aio_open() (lines 996-1002)
  Added safety check for proof->everything->tail before dereferencing
  Prevents crash when loading proofs with no premises

Fixes: kovzol#27
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your work on this!
I think, the word "dest" was accidentally changed to "dest/src/config.h.in" which is clearly an issue. Please revise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for reporting this! I've searched but I'm unable to locate the issue. Could you please point me to the exact file or line number where "dest" was incorrectly changed? That would help me fix it quickly.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@Alvi16
Copy link
Copy Markdown
Author

Alvi16 commented Mar 27, 2026

@kovzol It's good. I think all the changes have been made. You can take a look.

@kovzol
Copy link
Copy Markdown
Owner

kovzol commented Mar 31, 2026

Thanks, I'll have a look soon.

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