Butterbur: Fixed double free, freeing VBO, freeing nodes
authorJerome St-Louis <jerome@ecere.com>
Sun, 20 Sep 2015 15:55:32 +0000 (00:55 +0900)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:26:40 +0000 (20:26 -0400)
butterbur/src/butterbur.ec

index 425dadf..c7ed827 100644 (file)
@@ -144,9 +144,16 @@ class BBPath : BBObject
    CapType cap;
    bool closed;
    bool noJoin;
-   int lineCount;
+   int lineCount, fillCount;
    lineColor = black;
 
+   ~BBPath()
+   {
+      fillIndices.free();
+      lineIndices.free();
+      vbo.free();
+   }
+
    property ColorAlpha lineColor
    {
       set { lineColor = value; }
@@ -350,11 +357,14 @@ class BBPath : BBObject
          delete points;
 
       if(closed)
+      {
          fillIndices.upload(tc * sizeof(uint16), ixFill);
+         fillCount = tc;
+      }
 
-      delete ixFill;
       if(ixFill != ix)
          delete ix;
+      delete ixFill;
    }
 
    void render()
@@ -365,7 +375,7 @@ class BBPath : BBObject
       if(closed)
       {
          glimtkColor4f(fillColor.color.r/255.0f, fillColor.color.g/255.0f, fillColor.color.b/255.0f, fillColor.a/255.0f);
-         fillIndices.draw(GLIMTKMode::triangleFan, nodes.count, glTypeUnsignedShort, null);
+         fillIndices.draw(GLIMTKMode::triangleFan, fillCount, glTypeUnsignedShort, null);
       }
 
       // Line
@@ -450,6 +460,7 @@ class BBRectangle : BBPath
       }
 
       BBPath::update();
+      nodes.Free();
    }
 }
 
@@ -488,6 +499,7 @@ class BBCircle : BBPath
       }
 
       BBPath::update();
+      nodes.Free();
    }
 }
 
@@ -528,5 +540,6 @@ class BBEllipse : BBPath
       }
 
       BBPath::update();
+      nodes.Free();
    }
 }