]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afs.c: Improve documentation of activate_mood_or_playlist().
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 17 Mar 2022 19:36:06 +0000 (20:36 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 24 Mar 2022 19:01:47 +0000 (20:01 +0100)
It is not obvious when arg and current_mop can alias each other so
add an explanatory comment.

afs.c

diff --git a/afs.c b/afs.c
index 031a00993ffec086a1fe447fb6d4f1bc528234fd..522615a31b742f937a814a7f53f9708339033ac4 100644 (file)
--- 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) {