From: rjk@greenend.org.uk <> Date: Sat, 7 Jul 2007 15:07:09 +0000 (+0100) Subject: find_track_root() now issues a log message if it finds a track outside X-Git-Tag: debian-1_5_99dev8~293 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/a8747834bb7d56ef1e57be5404824d6a638ba2d4 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. 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. --- 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)