Skip to content

Commit

Permalink
Check GDALGetRasterUnitType for null ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed May 12, 2022
1 parent 9990ed3 commit f747c81
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/raster/rasterband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,11 @@ impl<'a> RasterBand<'a> {
/// If there is no unit, the empty string is returned.
pub fn unit(&self) -> String {
let str_ptr = unsafe { gdal_sys::GDALGetRasterUnitType(self.c_rasterband) };

if str_ptr.is_null() {
return String::new();
}

_string(str_ptr)
}
}
Expand Down

0 comments on commit f747c81

Please sign in to comment.