Skip to content

Commit

Permalink
Check for stoi out_of_range for FITS header parsing (#1369)
Browse files Browse the repository at this point in the history
* Check for stoi out_of_range then convert header value to long

* Update changelog

---------

Co-authored-by: Pam Harris <[email protected]>
  • Loading branch information
pford and pford authored May 6, 2024
1 parent a97ee32 commit 5d7d057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
* Fix crash when parsing FITS header long value ([#1366](https://github.com/CARTAvis/carta-backend/issues/1366)).

### Changed
* Move the loader cache to separate files ([#1021](https://github.com/CARTAvis/carta-backend/issues/1021)).
* Improve the code style in HTTP server ([#1260](https://github.com/CARTAvis/carta-backend/issues/1260)).
Expand Down
4 changes: 4 additions & 0 deletions src/ImageData/CompressedFits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ void CompressedFits::AddHeaderEntry(
} catch (std::invalid_argument) {
// Set string value only
entry->set_entry_type(CARTA::EntryType::STRING);
} catch (std::out_of_range) {
long lvalue = std::stol(value);
entry->set_numeric_value(lvalue);
entry->set_entry_type(CARTA::EntryType::INT);
}
}
}
Expand Down

0 comments on commit 5d7d057

Please sign in to comment.