From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 7 Dec 2021 19:58:00 +0000 (+0000) Subject: Fix a few more memory leaks X-Git-Tag: 4.1-rc1~24^2~363^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7258a45bea6cac73fe581f41df177470120b4dfa;p=thirdparty%2Fshairport-sync.git Fix a few more memory leaks --- diff --git a/mdns_avahi.c b/mdns_avahi.c index 95984419..7103b1ee 100644 --- a/mdns_avahi.c +++ b/mdns_avahi.c @@ -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 076ba702..6f46c3f5 100644 --- 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); // } diff --git a/shairport.c b/shairport.c index ecba335a..e2fd0b5e 100644 --- a/shairport.c +++ b/shairport.c @@ -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!");