]> granicus.if.org Git - graphviz/commitdiff
gdiplus plugin: make 'FileStream' destructor virtual
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 20 Nov 2021 15:56:56 +0000 (07:56 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 24 Nov 2021 15:47:40 +0000 (07:47 -0800)
`FileStream::Release` optionally deletes `this`. This is OK because nothing
inherits from `FileStream`, but the compiler believes this is dangerous because
this class participates in an inheritance hierarchy and does not have a virtual
destructor. By giving it one, we silence the -Wdelete-non-virtual-dtor warning,
make it safer to inherit from this class in future, and make it safe to delete
a `FileStream` through an `IStream` pointer.

plugin/gdiplus/FileStream.h

index 0157d738f1a990cd1cd76d91e3218f046dab2d35..2de81e76e862e388961ba0f30947ef2bb533e432 100644 (file)
@@ -81,6 +81,8 @@ public:
        virtual HRESULT STDMETHODCALLTYPE  Clone( 
                IStream **ppstm);
         
+       virtual ~FileStream() = default;
+
 private:
        FileStream(char *name, FILE *file);