Changes between Version 37 and Version 38 of Ticket #86
- Timestamp:
- Nov 21, 2007, 2:26:18 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #86 – Description
v37 v38 17 17 18 18 // 'points' WILL LEAK WHEN EXCEPTION ABOVE IS THROWN 19 points=newCoords; // <--- [1]19 points=newCoords; // <--- 1 20 20 } 21 21 … … 60 60 3. LineString ctor recognizes this sequence as invalid and throws IllegalArgumentException 61 61 62 4. 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 null62 4. 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 63 64 5. When exception is thrown in line [3], the LineString destructor is called but 'points' is null, so the sequence is not deallocated (BUM!)64 5. When exception is thrown in line 3, the LineString destructor is called but 'points' is null, so the sequence is not deallocated (BUM!) 65 65 66 66 6. Finally, sequnce 'pseq' leaks 67 67 68 7. To avoid the memory leaks, temporary solution is to deallocate it on the client side, when exception is catched, in line [4].68 7. To avoid the memory leaks, temporary solution is to deallocate it on the client side, when exception is catched, in line 4. 69 69 70 70 The main problem is that LineString ctor does not promises (prepares LineString object well) that all resources LineString is responsible for will be deallocated by dctor in case of problems. 71 71 72 The simplest possible solution is to move line [1]:73 points=newCoords; // <--- [1]72 The simplest possible solution is to move line 1: 73 points=newCoords; // <--- 1 74 74 75 75 to the beginning of the LineString::LineString().