chiark / gitweb /
server/schedule.c: Maintain separate variables for raw and resolved tracks. 5.2.x
authorMark Wooding <mdw@distorted.org.uk>
Tue, 5 May 2020 19:06:05 +0000 (20:06 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 5 May 2020 22:17:44 +0000 (23:17 +0100)
GCC 9 correctly points out that, if `trackdb_resolve' fails, we try to
print a null pointer in the error message, rather than the offending
track name.

Fix this by not reusing the same variable for two different jobs with
overlapping lifetimes.

server/schedule.c

index 219fc14b50de3f74179d9c0af61d4c713ef5e69c..520ae2e6e38736b8845e356611f909a7bd742ed3 100644 (file)
@@ -359,6 +359,7 @@ static void schedule_play(ev_source *ev,
                          const char *who,
                          struct kvp *actiondata) {
   const char *track = kvp_get(actiondata, "track");
+  const char *rtrack = 0;
   struct queue_entry *q;
 
   /* This stuff has rather a lot in common with c_play() */
@@ -370,12 +371,12 @@ static void schedule_play(ev_source *ev,
     disorder_error(0, "scheduled event %s: no such track as %s", id, track);
     return;
   }
-  if(!(track = trackdb_resolve(track))) {
+  if(!(rtrack = trackdb_resolve(track))) {
     disorder_error(0, "scheduled event %s: cannot resolve track %s", id, track);
     return;
   }
-  disorder_info("scheduled event %s: %s play %s", id,  who, track);
-  q = queue_add(track, who, WHERE_START, NULL, origin_scheduled);
+  disorder_info("scheduled event %s: %s play %s", id,  who, rtrack);
+  q = queue_add(rtrack, who, WHERE_START, NULL, origin_scheduled);
   queue_write();
   if(q == qhead.next && playing)
     prepare(ev, q);