From cf30c2c6e5166be720a6cfbbe416b1a82cc88a3c Mon Sep 17 00:00:00 2001
From: moon2 <moon2protonmail@protonmail.com>
Date: Sun, 6 Aug 2023 21:22:08 +0200
Subject: [PATCH] bl00mbox: no more memset

---
 components/bl00mbox/.clang-tidy     |  2 +-
 components/bl00mbox/bl00mbox_user.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/components/bl00mbox/.clang-tidy b/components/bl00mbox/.clang-tidy
index cce6d6580c..8797ef9f00 100644
--- a/components/bl00mbox/.clang-tidy
+++ b/components/bl00mbox/.clang-tidy
@@ -1 +1 @@
-Checks: '-clang-diagnostic-incompatible-pointer-types'
+Checks: '-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-diagnostic-deprecated-declarations,-clang-diagnostic-incompatible-pointer-types'
diff --git a/components/bl00mbox/bl00mbox_user.c b/components/bl00mbox/bl00mbox_user.c
index ba72abf923..1544915dd9 100644
--- a/components/bl00mbox/bl00mbox_user.c
+++ b/components/bl00mbox/bl00mbox_user.c
@@ -388,7 +388,10 @@ bool bl00mbox_channel_connect_signal_to_output_mixer(
     if (root == NULL) return false;
     bl00mbox_connection_subscriber_t *sub =
         malloc(sizeof(bl00mbox_connection_subscriber_t));
-    if (sub == NULL) return false;
+    if (sub == NULL){
+        free(root);
+        return false;
+    }
 
     bl00mbox_connection_t *conn;
     if (tx->buffer == NULL) {  // doesn't feed a buffer yet
@@ -408,7 +411,11 @@ bool bl00mbox_channel_connect_signal_to_output_mixer(
         if (conn->subs != NULL) {
             bl00mbox_connection_subscriber_t *seek = conn->subs;
             while (seek != NULL) {
-                if (seek->type == 1) return false;  // already connected
+                if (seek->type == 1){
+                    free(root);
+                    free(sub);
+                    return false;  // already connected
+                }
                 seek = seek->next;
             }
         }
-- 
GitLab