]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix a few more memory leaks
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 7 Dec 2021 19:58:00 +0000 (19:58 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 7 Dec 2021 19:58:00 +0000 (19:58 +0000)
mdns_avahi.c
rtsp.c
shairport.c

index 959844198f9374646714affc08c9916ea5aa0ad4..7103b1eeb98786effac4e5038413478ddf9ad402 100644 (file)
@@ -112,7 +112,7 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn
           char portstring[20];
           memset(portstring, 0, sizeof(portstring));
           snprintf(portstring, sizeof(portstring), "%u", port);
-          send_ssnc_metadata('dapo', strdup(portstring), strlen(portstring), 0);
+          send_ssnc_metadata('dapo', portstring, strlen(portstring), 0);
 #endif
         }
       } else {
diff --git a/rtsp.c b/rtsp.c
index 076ba70253ed0b9ce42de953ee29a8d006e0c994..6f46c3f53e2f119fa8483387744e0e0a615598c8 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -2282,7 +2282,7 @@ void handle_command(__attribute__((unused)) rtsp_conn_info *conn, rtsp_message *
       if (item != NULL) {
         char *typeValue = NULL;
         plist_get_string_val(item, &typeValue);
-        if (strcmp(typeValue, "updateMRSupportedCommands") == 0) {
+        if ((typeValue != NULL) && (strcmp(typeValue, "updateMRSupportedCommands") == 0)) {
           item = plist_dict_get_item(command_dict, "params");
           if (item != NULL) {
             // the item should be a dict
@@ -2331,6 +2331,8 @@ void handle_command(__attribute__((unused)) rtsp_conn_info *conn, rtsp_message *
                 "POST /command plist type is \"%s\", but \"updateMRSupportedCommands\" expected.",
                 typeValue);
         }
+        if (typeValue != NULL)
+          free(typeValue);
       } else {
         debug(1, "Could not get the \"type\" item.");
       }
@@ -2523,6 +2525,10 @@ void handle_teardown_2(rtsp_conn_info *conn, __attribute__((unused)) rtsp_messag
     debug(1, "Connection %d: missing plist!", conn->connection_number);
     resp->respcode = 451; // don't know what to do here
   }
+  if (conn->dacp_active_remote != NULL) {
+    free(conn->dacp_active_remote);
+    conn->dacp_active_remote = NULL;
+  }
   debug(1,"Bogus exit for valgrind.");
   exit(EXIT_SUCCESS); // 
 }
index ecba335a4fac937bdad5797b61ce62aab4c681a6..e2fd0b5e96de0ebf84201a1b4a43a8ed06a4a92d 100644 (file)
@@ -1843,7 +1843,7 @@ int main(int argc, char **argv) {
   char *uuid = malloc(UUID_STR_LEN);
   // Produces a UUID string at uuid consisting of lower-case letters
   uuid_unparse_lower(binuuid, uuid);
-  config.airplay_pi = strdup(uuid);
+  config.airplay_pi = uuid;
   debug(1, "Started in Airplay 2 mode on device \"%s\"!", config.airplay_device_id);
 #else
   debug(1, "Started in Airplay 1 mode!");