From 4c4f5416a8a4e6621e24223be796406ec1361c95 Mon Sep 17 00:00:00 2001 From: odudex Date: Fri, 6 Nov 2026 15:13:41 -0300 Subject: [PATCH 1/2] fix(bindings): drop the dead free on the UREncoder.next_part failure path ur_encoder_next_part() writes the part only on success, so both modules' free on failure never ran. In the MicroPython module it made static analysis report a use-after-free at the return, because the scanner did not treat mp_raise_msg() as noreturn. --- python/uUR.c | 1 - uUR.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/python/uUR.c b/python/uUR.c index 16d6b13..69b43a3 100644 --- a/python/uUR.c +++ b/python/uUR.c @@ -573,7 +573,6 @@ static PyObject *UREncoder_next_part(uUR_UREncoder *self, PyObject *ignored) { char *part = NULL; bool ok = ur_encoder_next_part(self->encoder, &part); if (!ok) { - free(part); PyErr_SetString(PyExc_RuntimeError, "Failed to generate next part"); return NULL; } diff --git a/uUR.c b/uUR.c index def8f62..123d5d3 100644 --- a/uUR.c +++ b/uUR.c @@ -551,9 +551,6 @@ static mp_obj_t ur_encoder_next_part_py(mp_obj_t self_in) { bool result = ur_encoder_next_part(self->encoder, &ur_part); if (!result) { - if (ur_part) { - free(ur_part); - } mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Failed to generate next part")); } From 474adeb67983ed6ef8eca2592f41eacacdc3c552 Mon Sep 17 00:00:00 2001 From: odudex Date: Fri, 6 Nov 2026 15:17:14 -0300 Subject: [PATCH 2/2] ci: restrict the workflow token to read-only contents test.yml sets a top-level permissions block with contents: read. Its jobs only check out, format-check and build, so none needs write access, and jobs added later inherit the read-only token. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a483432..8d5f816 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: +permissions: + contents: read + jobs: format: name: clang-format check