From: Andre Noll Date: Sun, 20 Feb 2011 11:50:37 +0000 (+0100) Subject: audiod: Fix a memory leak in parse_receiver_args(). X-Git-Tag: v0.4.6~40 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=540e19319a41ee5ed74565d40f9bf49867747b2c audiod: Fix a memory leak in parse_receiver_args(). If multiple receivers are given, we leak the config structure of all but the last one. Clean up a comment further down in the function while we're at it. --- diff --git a/audiod.c b/audiod.c index 64ea8a51..8b17d95f 100644 --- a/audiod.c +++ b/audiod.c @@ -823,6 +823,14 @@ static int parse_receiver_args(void) ret = get_audio_format_num(arg); if (ret < 0) goto out; + /* + * If multiple receivers are given for this audio format, the + * last one wins and we have to free the previous receiver + * config here. Since we are iterating backwards, the winning + * receiver arg is in fact the first one given. + */ + if (afi[ret].receiver_conf) + afi[ret].receiver->free_config(afi[ret].receiver_conf); afi[ret].receiver_conf = check_receiver_arg(recv_arg, &receiver_num); if (!afi[ret].receiver_conf) { ret = -E_RECV_SYNTAX; @@ -830,9 +838,9 @@ static int parse_receiver_args(void) } afi[ret].receiver = &receivers[receiver_num]; } - /* use the first available receiver with no arguments - * for those audio formats for which no receiver - * was specified + /* + * Use the first available receiver with no arguments for those audio + * formats for which no receiver was specified. */ cmd = para_strdup(receivers[0].name); FOR_EACH_AUDIO_FORMAT(i) {