From 425bd709b2df8dc2754678ca28c91b1534d26078 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 17 Mar 2022 20:36:06 +0100 Subject: [PATCH] afs.c: Improve documentation of activate_mood_or_playlist(). It is not obvious when arg and current_mop can alias each other so add an explanatory comment. --- afs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/afs.c b/afs.c index 031a0099..522615a3 100644 --- a/afs.c +++ b/afs.c @@ -481,6 +481,12 @@ static int activate_mood_or_playlist(const char *arg, int *num_admissible, if (num_admissible) *num_admissible = ret; current_play_mode = mode; + /* + * We get called with arg == current_mop from the signal dispatcher + * after SIGHUP and from the error path of the select command to + * re-select the current mood or playlist. In this case the assignment + * to current_mop below would result in a use-after-free condition. + */ if (arg != current_mop) { free(current_mop); if (arg) { -- 2.39.5