From 0ba13be4beacb2dbc7d24aede084fbeb32581341 Mon Sep 17 00:00:00 2001 From: "David W. Berry" Date: Tue, 22 Jun 2004 01:52:26 +0000 Subject: [PATCH] fix problem with m4p files crashing sorting --- src/db-gdbm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/db-gdbm.c b/src/db-gdbm.c index 4da3f311..75133750 100644 --- a/src/db-gdbm.c +++ b/src/db-gdbm.c @@ -787,11 +787,21 @@ void db_freefile(MP3FILE *pmp3) { * this should be done quickly, as we'll be holding * a reader lock on the db */ +static int nullstrcmp(const char* a, const char* b) +{ + if(a == 0) + return b == 0 ? 1 : 0; + if(b == 0) + return -1; + + return strcmp(a, b); +} + int compare(MP3RECORD* a, MP3RECORD* b) { int comp; - if((comp = strcmp(a->mp3file.album, b->mp3file.album)) != 0) + if((comp = nullstrcmp(a->mp3file.album, b->mp3file.album)) != 0) return comp; if((comp = (a->mp3file.disc - b->mp3file.disc)) != 0)