Changeset 80

Show
Ignore:
Timestamp:
04/17/06 09:21:47 (3 years ago)
Author:
jordi
Message:

All setters function from IDocument now frees the argumen after copying it to the attribute. That's because I though that a "double free or invalid pointer" was caused by any of them, but it seems that it was the test code that did pass a const char, when a copy of it should have been passed. This didn't happen on "debug mode"...

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/IDocument.cxx

    r78 r80  
    188188IDocument::setTitle (gchar *title) 
    189189{ 
    190     g_free (m_Title); 
    191     m_Title = title; 
     190    gchar *oldTitle = m_Title; 
     191    m_Title = g_strdup (title); 
     192    g_free (oldTitle); 
     193    g_free (title); 
    192194} 
    193195 
     
    216218IDocument::setAuthor (gchar *author) 
    217219{ 
    218     g_free (m_Author); 
    219     m_Author = author; 
     220    gchar *oldAuthor = m_Author; 
     221    m_Author = g_strdup (author); 
     222    g_free (oldAuthor); 
     223    g_free (author); 
    220224} 
    221225 
     
    244248IDocument::setSubject (gchar *subject) 
    245249{ 
    246     g_free (m_Subject); 
     250    gchar *oldSubject = m_Subject; 
     251    m_Subject = g_strdup (subject); 
     252    g_free (oldSubject); 
    247253    m_Subject = subject; 
    248254} 
     
    273279IDocument::setKeywords (gchar *keywords) 
    274280{ 
    275     g_free (m_Keywords); 
    276     m_Keywords = keywords; 
     281    gchar *oldKeywords = m_Keywords; 
     282    m_Keywords = g_strdup (keywords); 
     283    g_free (oldKeywords); 
     284    g_free (keywords); 
    277285} 
    278286 
     
    302310IDocument::setCreator (gchar *creator) 
    303311{ 
    304     g_free (m_Creator); 
    305     m_Creator = creator; 
     312    gchar *oldCreator = m_Creator; 
     313    m_Creator = g_strdup (creator); 
     314    g_free (oldCreator); 
     315    g_free (creator); 
    306316} 
    307317/// 
     
    330340IDocument::setProducer (gchar *producer) 
    331341{ 
    332     g_free (m_Producer); 
    333     m_Producer = producer; 
     342    gchar *oldProducer = m_Producer; 
     343    m_Producer = g_strdup (producer); 
     344    g_free (oldProducer); 
     345    g_free (producer); 
    334346} 
    335347 
     
    360372IDocument::setFormat (gchar *format) 
    361373{ 
    362     g_free (m_Format); 
    363     m_Format = format; 
     374    gchar *oldFormat = m_Format; 
     375    m_Format = g_strdup (format); 
     376    g_free (oldFormat); 
     377    g_free (format); 
    364378} 
    365379 
     
    390404IDocument::setLinearized (gchar *linearized) 
    391405{ 
    392     g_free (m_Linearized); 
    393     m_Linearized = linearized; 
     406    gchar *oldLinearized = m_Linearized; 
     407    m_Linearized = g_strdup (linearized); 
     408    g_free (oldLinearized); 
     409    g_free (linearized); 
    394410} 
    395411 
     
    419435IDocument::setCreationDate (gchar *date) 
    420436{ 
    421     g_free (m_CreationDate); 
    422     m_CreationDate = date; 
     437    gchar *oldCreationDate = m_CreationDate; 
     438    m_CreationDate = g_strdup (date); 
     439    g_free (oldCreationDate); 
     440    g_free (date); 
    423441} 
    424442 
     
    448466IDocument::setModifiedDate (gchar *date) 
    449467{ 
    450     g_free (m_ModifiedDate); 
    451     m_ModifiedDate = date; 
     468    gchar *oldModifiedDate = m_ModifiedDate; 
     469    m_ModifiedDate = g_strdup (date); 
     470    g_free (oldModifiedDate); 
     471    g_free (date); 
    452472} 
    453473 
  • trunk/tests/MainPterTest.cxx

    r73 r80  
    112112 
    113113    // Now try a document with a title. 
    114     m_Document->setTitle ("Test PDF"); 
     114    m_Document->setTitle (g_strdup ("Test PDF")); 
    115115    m_MainPter->openFileActivated (); 
    116116    CPPUNIT_ASSERT_EQUAL (0,