Skip to content

Commit

Permalink
Add assertion to histogram setter and getter
Browse files Browse the repository at this point in the history
  • Loading branch information
spadarian authored and lnicola committed Dec 4, 2023
1 parent ea341a8 commit f37c7de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/raster/rasterband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,14 @@ impl<'a> RasterBand<'a> {
///
/// * `min` - Histogram lower bound
/// * `max` - Histogram upper bound
/// * `n_buckets` - Number of buckets in the histogram
/// * `counts` - Histogram values for each bucket
///
/// # Panics
/// Panics if the `counts.len()` is greater than `i32::MAX`.
pub fn set_default_histogram(&self, min: f64, max: f64, counts: &mut [u64]) -> Result<()> {
let n_buckets = counts.len();
assert!(n_buckets <= i32::MAX as usize);

let rv = unsafe {
GDALSetDefaultHistogramEx(
self.c_rasterband,
Expand Down Expand Up @@ -933,6 +937,8 @@ impl<'a> RasterBand<'a> {
));
}

assert!(n_buckets <= i32::MAX as usize);

let mut counts = vec![0; n_buckets];

let rv = unsafe {
Expand Down

0 comments on commit f37c7de

Please sign in to comment.