File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 76
76
` SpatialRef::axis_mapping_strategy ` instead.
77
77
* Add support for reading and setting rasterband colour interpretations
78
78
* < https://github.com/georust/gdal/pull/144 >
79
+ * Fixed memory leak in ` Geometry::from_wkt `
80
+ * < https://github.com/georust/gdal/pull/172 >
81
+
79
82
## 0.7.1
80
83
* fix docs.rs build for gdal-sys
81
84
* < https://github.com/georust/gdal/pull/128 >
Original file line number Diff line number Diff line change 1
1
use crate :: spatial_ref:: { CoordTransform , SpatialRef } ;
2
2
use crate :: utils:: { _last_null_pointer_err, _string} ;
3
3
use gdal_sys:: { self , OGRErr , OGRGeometryH , OGRwkbGeometryType } ;
4
- use libc:: { c_double, c_int, c_void} ;
4
+ use libc:: { c_char , c_double, c_int, c_void} ;
5
5
use std:: cell:: RefCell ;
6
6
use std:: ffi:: CString ;
7
7
use std:: fmt:: { self , Debug } ;
@@ -75,7 +75,9 @@ impl Geometry {
75
75
/// [WKT](https://en.wikipedia.org/wiki/Well-known_text) string.
76
76
pub fn from_wkt ( wkt : & str ) -> Result < Geometry > {
77
77
let c_wkt = CString :: new ( wkt) ?;
78
- let mut c_wkt_ptr = c_wkt. into_raw ( ) ;
78
+ // OGR_G_CreateFromWkt does not write to the pointed-to memory, but this is not reflected
79
+ // in its signature (`char**` instead of `char const**`), so we need a scary looking cast.
80
+ let mut c_wkt_ptr = c_wkt. as_ptr ( ) as * mut c_char ;
79
81
let mut c_geom = null_mut ( ) ;
80
82
let rv = unsafe { gdal_sys:: OGR_G_CreateFromWkt ( & mut c_wkt_ptr, null_mut ( ) , & mut c_geom) } ;
81
83
if rv != OGRErr :: OGRERR_NONE {
You can’t perform that action at this time.
0 commit comments