From 8376354696f20d23e04c4a679cf2e94effd555b1 Mon Sep 17 00:00:00 2001 From: forcer Date: Sat, 29 Apr 2006 18:54:00 +0000 Subject: emms-print-metadata.c: Don't segfault if argument doesn't exist. darcs-hash:20060429185448-2189f-d25bfe8317afd3be16e5d2b4cb8c32b0724568e0.gz --- emms-print-metadata.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/emms-print-metadata.c b/emms-print-metadata.c index 3157f46..9bf6352 100644 --- a/emms-print-metadata.c +++ b/emms-print-metadata.c @@ -35,8 +35,24 @@ main (int argc, char **argv) } file = taglib_file_new (argv[1]); + + if (!file) + { + fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]); + exit (1); + } + tag = taglib_file_tag (file); + /* Apparently, if the file is named foo.mp3 or similar, the library + still can open it, for whatever reason. + */ + if (!tag) + { + fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]); + exit (1); + } + printf ("info-artist=%s\n", taglib_tag_artist (tag)); printf ("info-title=%s\n", taglib_tag_title (tag)); printf ("info-album=%s\n", taglib_tag_album (tag)); -- cgit v1.2.3