Skip to content

fix: add NULL pointer check in scanner.c (CWE-476) - #377

Open
anupamme wants to merge 1 commit into
DerekStride:mainfrom
anupamme:fix-repo-tree-sitter-sql-scanner-null-check-cwe-476
Open

anupamme wants to merge 1 commit into
DerekStride:mainfrom
anupamme:fix-repo-tree-sitter-sql-scanner-null-check-cwe-476

Conversation

@anupamme

Copy link
Copy Markdown

Multiple malloc calls in src/scanner.c do not check for NULL return values before dereferencing the allocated pointer. At line 19, malloc(sizeof(LexerState)) is not checked before accessing state->start_tag. At line 35, malloc result is assigned to text and immediately used. At line 42, malloc result is assigned to tmp and used. At line 56, malloc result is assigned to text_size and used. Under memory pressure, these allocations can fail and return NULL, causing immediate segmentation fault when dereferenced. The affected code is src/scanner.c:18, and this change addresses it.

Reference: CWE-476

What changed

  • src/scanner.c

Verification

No automated check could be run against this repository, so this change is unverified beyond review. Please treat it as a suggestion.

Automated security fix generated by OrbisAI Security

This branch has not been deployed

No deployments
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