From: Lukáš Lalinský Date: Sat, 24 Oct 2009 12:45:58 +0000 (+0000) Subject: Return NULL/false rather than crash when accessing file attributes in FileRef X-Git-Tag: v1.6.1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bffd4da8b66bd8e72aae0302b7b70d5344a8578f;p=taglib Return NULL/false rather than crash when accessing file attributes in FileRef BUG:209417 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1039724 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 93a72407..e5d0feaf 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "fileref.h" #include "asffile.h" @@ -93,11 +94,19 @@ FileRef::~FileRef() Tag *FileRef::tag() const { + if(isNull()) { + debug("FileRef::tag() - Called without a valid file."); + return 0; + } return d->file->tag(); } AudioProperties *FileRef::audioProperties() const { + if(isNull()) { + debug("FileRef::audioProperties() - Called without a valid file."); + return 0; + } return d->file->audioProperties(); } @@ -108,6 +117,10 @@ File *FileRef::file() const bool FileRef::save() { + if(isNull()) { + debug("FileRef::save() - Called without a valid file."); + return false; + } return d->file->save(); }