[01/10] libsframe: null check arg before writing to in sframe_encoder_write

Message ID 20260827224146.3391610-2-ibhagatgnu@gmail.com
State New
Headers
Series fix two PRs and guard against bad data |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Indu Bhagat Aug. 27, 2026, 10:41 p.m. UTC
  Check for encoder_size == NULL before writing to it.
---
 libsframe/sframe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index cd6bb3022db..011884c0768 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -2708,7 +2708,8 @@  sframe_encoder_write (sframe_encoder_ctx *ectx, size_t *encoded_size,
   /* Initialize the encoded_size to zero.  This makes it simpler to just
      return from the function in case of failure.  Free'ing up of
      ectx->sfe_data is the responsibility of the caller.  */
-  *encoded_size = 0;
+  if (encoded_size != NULL)
+    *encoded_size = 0;
 
   if (ectx == NULL || encoded_size == NULL || errp == NULL)
     return sframe_ret_set_errno (errp, SFRAME_ERR_INVAL);