]> git.sesse.net Git - movit/commitdiff
Fix a leak in DiffusionEffect in an edge case.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Apr 2014 00:16:14 +0000 (02:16 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Apr 2014 00:16:14 +0000 (02:16 +0200)
Found by Coverity Scan.

diffusion_effect.cpp
diffusion_effect.h

index 145eaf695860608040afec87bc0120eb08188c6d..afec9c80805490a97404d6e0c6e118759982dd9b 100644 (file)
@@ -12,10 +12,18 @@ namespace movit {
 
 DiffusionEffect::DiffusionEffect()
        : blur(new BlurEffect),
-         overlay_matte(new OverlayMatteEffect)
+         overlay_matte(new OverlayMatteEffect),
+         owns_overlay_matte(true)
 {
 }
 
+DiffusionEffect::~DiffusionEffect()
+{
+       if (owns_overlay_matte) {
+               delete overlay_matte;
+       }
+}
+
 void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
 {
        assert(self->incoming_links.size() == 1);
@@ -23,6 +31,7 @@ void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
 
        Node *blur_node = graph->add_node(blur);
        Node *overlay_matte_node = graph->add_node(overlay_matte);
+       owns_overlay_matte = false;
        graph->replace_receiver(self, overlay_matte_node);
        graph->connect_nodes(input, blur_node);
        graph->connect_nodes(blur_node, overlay_matte_node);
index 82eda939779b1addd847a9aa7d1cf4640817b7c0..64b94dd8dad11df184e3fb082ec622ab13186644 100644 (file)
@@ -28,6 +28,7 @@ class OverlayMatteEffect;
 class DiffusionEffect : public Effect {
 public:
        DiffusionEffect();
+       ~DiffusionEffect();
        virtual std::string effect_type_id() const { return "DiffusionEffect"; }
 
        virtual void rewrite_graph(EffectChain *graph, Node *self);
@@ -43,6 +44,7 @@ public:
 private:
        BlurEffect *blur;
        OverlayMatteEffect *overlay_matte;
+       bool owns_overlay_matte;
 };
 
 // Used internally by DiffusionEffect; combines the blurred and the original