Changes between Initial Version and Version 37 of Ticket #86


Ignore:
Timestamp:
Nov 21, 2007, 2:24:38 PM (16 years ago)
Author:
mloskot
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #86

    • Property Severity SignificantUnassigned
    • Property Reporter changed from mateusz@… to mloskot
    • Property Component CoreBuild scripts
    • Property Version 3.0.02.2.3
  • Ticket #86 – Description

    initial v37  
    1 {{{
    21There is a high possibility that constructor of LineString class will cause memory leaks.
    32
    43Here is small snipped with current version of this ctor:
    54
     5{{{
    66LineString::LineString(CoordinateSequence* newCoords, const GeometryFactory *factory)
    77   : Geometry(factory)
     
    2020}
    2121
    22 Now, the small piece of code with how I create LineString object in one of my test.
    23 This test tries to create one-point linestring intentionaly.
     22}}}
    2423
     24Now, the small piece of code with how I create LineString object in one of my test. This test tries to create one-point linestring intentionaly.
     25
     26{{{
    2527void test()
    2628{
     
    4850}
    4951
     52}}}
    5053
    5154Now, the explanation:
    5255
    53561. New coordiante sequence is created with only one point
     57
    54582. New linestringis created with one-point sequence that is expected to be invalid
     59
    55603. LineString ctor recognizes this sequence as invalid and throws IllegalArgumentException
     61
    56624. At this moment, the line [1] is not called, so the sequence previously created does not become a part of LineString object and LineString::points member is left as null
     63
    57645. When exception is thrown in line [3], the LineString destructor is called but 'points' is null, so the sequence is not deallocated (BUM!)
     65
    58666. Finally, sequnce 'pseq' leaks
     67
    59687. To avoid the memory leaks, temporary solution is to deallocate it on the client side, when exception is catched, in line [4].
    6069
     
    6877If newCoords is not a null pointer, then the sequence will be assigned to points member and in case of exception,
    6978LineString destructor will deallocated it properly.
    70 }}}