Skip to content

Commit

Permalink
Add some asserts to Dataset::rasterband
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Sep 13, 2023
1 parent 8b023b9 commit 26c436f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ impl Dataset {
/// Applies to raster datasets, and fetches the
/// rasterband at the given _1-based_ index.
pub fn rasterband(&self, band_index: usize) -> Result<RasterBand> {
assert!(band_index > 0);
assert!(band_index <= c_int::MAX as usize);

unsafe {
let c_band = gdal_sys::GDALGetRasterBand(self.c_dataset, band_index as c_int);
if c_band.is_null() {
Expand Down

0 comments on commit 26c436f

Please sign in to comment.