Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#3 memory leak in cairo path freeing

closed-accepted
None
5
2007-10-27
2007-08-31
Anonymous
No

There is a memory leak in shape.cpp when freeing the Path returned by the method copy_path() of Cairo::Context. free() is used where delete should be (a call to cairo_path_destroy is thus missing).

Here is a patch to apply to shape.cpp:

--- papyrus-0.7.1/papyrus/shape.cpp 2007-01-14 06:04:09.000000000 +0100
+++ papyrus-0.7.1-work/papyrus/shape.cpp 2007-09-01 01:06:22.000000000 +0200
@@ -48,9 +48,9 @@

Shape::~Shape() {
if ( m_fill_path )
- free( m_fill_path );
+ delete m_fill_path;
if ( m_outline_path )
- free( m_outline_path );
+ delete m_outline_path;
}

@@ -173,14 +173,13 @@
void Shape::shape_changed( unsigned which )
{
if ( which & FILL ) {
- free( m_fill_path );
+ delete m_fill_path;
m_fill_path = NULL;
}
if ( which & OUTLINE ) {
- free( m_outline_path );
+ delete m_outline_path;
m_outline_path = NULL;
}
this->need_redraw();
}
-
}

Discussion

  • Logged In: YES
    user_id=12236
    Originator: NO

    Thanks. You're absolutely right. For some reason I was thinking the cairo calls were underneath which needed a free.

    It will be in CVS shortly and in the next release... which is coming RSN... with a first cut at SVG read support.

     
    • assigned_to: nobody --> rvinyard
    • status: open --> closed-accepted