From 004551faec42f07ea2ff737bcc764f8b1f8ce2c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Sat, 12 Dec 2009 16:44:34 +0000 Subject: [PATCH] Fix tagreader_c.c to not try to access invalid pointers BUG:218334 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1061671 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- examples/tagreader_c.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/examples/tagreader_c.c b/examples/tagreader_c.c index 0220e19a..04369926 100644 --- a/examples/tagreader_c.c +++ b/examples/tagreader_c.c @@ -51,23 +51,27 @@ int main(int argc, char *argv[]) tag = taglib_file_tag(file); properties = taglib_file_audioproperties(file); - printf("-- TAG --\n"); - printf("title - \"%s\"\n", taglib_tag_title(tag)); - printf("artist - \"%s\"\n", taglib_tag_artist(tag)); - printf("album - \"%s\"\n", taglib_tag_album(tag)); - printf("year - \"%i\"\n", taglib_tag_year(tag)); - printf("comment - \"%s\"\n", taglib_tag_comment(tag)); - printf("track - \"%i\"\n", taglib_tag_track(tag)); - printf("genre - \"%s\"\n", taglib_tag_genre(tag)); + if(tag != NULL) { + printf("-- TAG --\n"); + printf("title - \"%s\"\n", taglib_tag_title(tag)); + printf("artist - \"%s\"\n", taglib_tag_artist(tag)); + printf("album - \"%s\"\n", taglib_tag_album(tag)); + printf("year - \"%i\"\n", taglib_tag_year(tag)); + printf("comment - \"%s\"\n", taglib_tag_comment(tag)); + printf("track - \"%i\"\n", taglib_tag_track(tag)); + printf("genre - \"%s\"\n", taglib_tag_genre(tag)); + } - seconds = taglib_audioproperties_length(properties) % 60; - minutes = (taglib_audioproperties_length(properties) - seconds) / 60; + if(properties != NULL) { + seconds = taglib_audioproperties_length(properties) % 60; + minutes = (taglib_audioproperties_length(properties) - seconds) / 60; - printf("-- AUDIO --\n"); - printf("bitrate - %i\n", taglib_audioproperties_bitrate(properties)); - printf("sample rate - %i\n", taglib_audioproperties_samplerate(properties)); - printf("channels - %i\n", taglib_audioproperties_channels(properties)); - printf("length - %i:%02i\n", minutes, seconds); + printf("-- AUDIO --\n"); + printf("bitrate - %i\n", taglib_audioproperties_bitrate(properties)); + printf("sample rate - %i\n", taglib_audioproperties_samplerate(properties)); + printf("channels - %i\n", taglib_audioproperties_channels(properties)); + printf("length - %i:%02i\n", minutes, seconds); + } taglib_tag_free_strings(); taglib_file_free(file); -- 2.50.1