From a8747834bb7d56ef1e57be5404824d6a638ba2d4 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sat, 7 Jul 2007 16:07:09 +0100 Subject: [PATCH] find_track_root() now issues a log message if it finds a track outside any collection. Should make it clearer what's going on if something believes the answer and crashes. Organization: Straylight/Edgeware From: rjk@greenend.org.uk <> track_to_words() now includes a bodge for such tracks to avoid a crash. Ultimately the answer is to expunge such tracks from the database but while my db is in a bizarre state it's worth making the code a bit more robust. --- lib/trackname.c | 5 ++++- server/trackdb.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/trackname.c b/lib/trackname.c index 7a891b7..cef77b8 100644 --- a/lib/trackname.c +++ b/lib/trackname.c @@ -44,7 +44,10 @@ const char *find_track_root(const char *track) { && track[l] == '/') break; } - if(n >= config->collection.n) return 0; + if(n >= config->collection.n) { + error(0, "found track in no collection '%s'", track); + return 0; + } return config->collection.s[n].root; } diff --git a/server/trackdb.c b/server/trackdb.c index be1aea4..ae3a7e2 100644 --- a/server/trackdb.c +++ b/server/trackdb.c @@ -491,9 +491,12 @@ static char **track_to_words(const char *track, struct vector v; char **w; int nw; + const char *rootless = track_rootless(track); + if(!rootless) + rootless = track; /* bodge */ vector_init(&v); - if((w = words(casefold(strip_extension(track_rootless(track))), &nw))) + if((w = words(casefold(strip_extension(rootless)), &nw))) vector_append_many(&v, w, nw); for(; p; p = p->next) -- [mdw]