[gnome-commander: 1/2] Fix for -Wnonnull : check if dynamic_cast returned pointer is not null again




commit 04978fcdd9168505276ab5fd0fe84ddc19b2259a
Author: Mamoru TASAKA <mtasaka fedoraproject org>
Date:   Thu Feb 25 22:54:38 2021 +0900

    Fix for -Wnonnull : check if dynamic_cast returned pointer is not null again
    
    gcc11 warns the following:
    ```
    /builddir/build/BUILD/GIT/gnome-commander/_BUILDDIR/../src/tags/gnome-cmd-tags-taglib.cc: In function 
'getAudioProperties(GnomeCmdFileMetadata&, TagLib::AudioProperties const*)':
    /builddir/build/BUILD/GIT/gnome-commander/_BUILDDIR/../src/tags/gnome-cmd-tags-taglib.cc:163:41: warning: 
'this' pointer is null [-Wnonnull]
      163 |         if (oggProperties->vorbisVersion())
          |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
    ```
    
    oggProperties is the pointer returned by dynamic_cast. As non-null check for oggProperties
    is already written, do the check again here.

 src/tags/gnome-cmd-tags-taglib.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/tags/gnome-cmd-tags-taglib.cc b/src/tags/gnome-cmd-tags-taglib.cc
index 7e546cf7..a8e17a01 100644
--- a/src/tags/gnome-cmd-tags-taglib.cc
+++ b/src/tags/gnome-cmd-tags-taglib.cc
@@ -160,7 +160,7 @@ bool getAudioProperties(GnomeCmdFileMetadata &metadata, const TagLib::AudioPrope
 
     if (mpcProperties)
     {
-        if (oggProperties->vorbisVersion())
+        if (oggProperties && oggProperties->vorbisVersion())
             cout << "Audio.MPC.Version  " << mpcProperties->mpcVersion() << endl;
 
         return true;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]