aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorforcer <forcer>2006-04-29 18:54:00 +0000
committerforcer <mwolson@gnu.org>2006-04-29 18:54:00 +0000
commit8376354696f20d23e04c4a679cf2e94effd555b1 (patch)
tree586e77c71cdd86e6e834866a25e0afeaa497eea4
parent972e4c0446146b457e39cb5e3734404141aed533 (diff)
emms-print-metadata.c: Don't segfault if argument doesn't exist.
darcs-hash:20060429185448-2189f-d25bfe8317afd3be16e5d2b4cb8c32b0724568e0.gz
-rw-r--r--emms-print-metadata.c16
1 files changed, 16 insertions, 0 deletions
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));