Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dimensions getter when no dimensions are available #303

Merged
merged 1 commit into from Sep 3, 2022

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Sep 2, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

Fixes #298

r? @ChristianBeilschmidt

@ChristianBeilschmidt
Copy link
Contributor

Can you also change it here?

gdal/src/raster/mdarray.rs

Lines 101 to 110 in 5785928

pub fn dimensions(&self) -> Result<Vec<Dimension>> {
let mut num_dimensions: usize = 0;
let c_dimensions = unsafe { GDALMDArrayGetDimensions(self.c_mdarray, &mut num_dimensions) };
// `num_dimensions` is `0`, we can safely return an empty vector
// `GDALMDArrayGetDimensions` does not state that errors can occur
if num_dimensions > 0 && c_dimensions.is_null() {
return Err(_last_null_pointer_err("GDALMDArrayGetDimensions"));
}

@lnicola
Copy link
Member Author

lnicola commented Sep 2, 2022

Thanks, I forgot about that one!

@lnicola
Copy link
Member Author

lnicola commented Sep 3, 2022

bors r=ChristianBeilschmidt

@bors
Copy link
Contributor

bors bot commented Sep 3, 2022

Build succeeded:

@bors bors bot merged commit 6cb6433 into georust:master Sep 3, 2022
@lnicola lnicola deleted the dimensions-empty-vec branch September 3, 2022 05:30
@metasim metasim mentioned this pull request Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in mdarray::tests::test_attributes
2 participants