]> granicus.if.org Git - taglib/commitdiff
Return NULL/false rather than crash when accessing file attributes in FileRef
authorLukáš Lalinský <lalinsky@gmail.com>
Sat, 24 Oct 2009 12:45:58 +0000 (12:45 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Sat, 24 Oct 2009 12:45:58 +0000 (12:45 +0000)
BUG:209417

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1039724 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/fileref.cpp

index 93a72407aa057dfefc0fff407d5947ee3ca13afe..e5d0feaf84f348f56c165f9d75dfc841e350fadb 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <tfile.h>
 #include <tstring.h>
+#include <tdebug.h>
 
 #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();
 }