Skip to content

Add CodeQL query to check allocations do not exceed ensure_free#2101

Open
pguyot wants to merge 1 commit intoatomvm:mainfrom
pguyot:w07/add-codeql-ensure-free-size
Open

Add CodeQL query to check allocations do not exceed ensure_free#2101
pguyot wants to merge 1 commit intoatomvm:mainfrom
pguyot:w07/add-codeql-ensure-free-size

Conversation

@pguyot
Copy link
Collaborator

@pguyot pguyot commented Feb 15, 2026

The query also checks redundant ensure_free calls, i.e. calls
followed by another call with no allocation in between.

Fix errors found by the query:

  • Add a missing ensure_free in esp32 dac_driver.c
  • Fix and simplify allocation in adc_driver.c (fix misplaced
    parenthesis bug and merge two ensure_free calls into one)
  • Remove redundant ensure_free calls in otp_ssl.c (left over
    from removal of enif_make_resource which used to do its own
    ensure_free)
  • Remove a redundant ensure_free call in nif_erlang_fun_to_list

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@pguyot pguyot force-pushed the w07/add-codeql-ensure-free-size branch from eaf5720 to 3b69c44 Compare February 15, 2026 11:30
@pguyot pguyot marked this pull request as ready for review February 15, 2026 11:31
@pguyot pguyot force-pushed the w07/add-codeql-ensure-free-size branch from 3b69c44 to 6e79c18 Compare February 15, 2026 16:08
@pguyot pguyot marked this pull request as draft February 17, 2026 07:52
@pguyot pguyot force-pushed the w07/add-codeql-ensure-free-size branch from 6e79c18 to c90f8c9 Compare February 22, 2026 20:02
The query also checks redundant ensure_free calls, i.e. calls
followed by another call with no allocation in between.

Fix errors found by the query:
- Add a missing ensure_free in esp32 `dac_driver.c`
- Fix and simplify allocation in `adc_driver.c` (fix misplaced
  parenthesis bug and merge two ensure_free calls into one)
- Remove redundant ensure_free calls in `otp_ssl.c` (left over
  from removal of `enif_make_resource` which used to do its own
  ensure_free)
- Remove a redundant ensure_free call in `nif_erlang_fun_to_list`

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
@pguyot pguyot force-pushed the w07/add-codeql-ensure-free-size branch from c90f8c9 to aea7bf1 Compare March 9, 2026 22:03
@pguyot pguyot marked this pull request as ready for review March 9, 2026 22:04
@github-advanced-security
Copy link

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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.

4 participants