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

Indu Bhagat <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
Check for encoder_size == NULL before writing to it.
---
 libsframe/sframe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.