Skip to content

Commit

Permalink
Update spice::readValue to throw an exception if no values are read (D…
Browse files Browse the repository at this point in the history
…OI-USGS#5165)

* Modified spice::readValue to add check for numValuesRead

* Updated changelog

* Added an exception when no value is read in Spice::readValue
  • Loading branch information
AustinSanders authored Apr 5, 2023
1 parent ab4483e commit cd667c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ release.
### Fixed
- Updated README.md to remove remaining references to downloading data from discontinued rsync server [#5152](https://github.com/DOI-USGS/ISIS3/issues/5152)
- Fixed users not being able to modify planetographic projections in qmos
- Modified spice::readValue to add check for numValuesRead to stop reading garbase values [#4928](https://github.com/USGS-Astrogeology/ISIS3/issues/4928)

## [7.2.0] - 2022-12-07

Expand Down
10 changes: 7 additions & 3 deletions isis/src/base/objs/Spice/Spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,30 +1118,34 @@ namespace Isis {
gdpool_c(key.toLatin1().data(), (SpiceInt)index, 1,
&numValuesRead, &kernelValue, &found);

if (found)
if (found && numValuesRead > 0)
result = kernelValue;
}
else if (type == SpiceStringType) {
char kernelValue[512];
gcpool_c(key.toLatin1().data(), (SpiceInt)index, 1, sizeof(kernelValue),
&numValuesRead, kernelValue, &found);

if (found)
if (found && numValuesRead > 0)
result = kernelValue;
}
else if (type == SpiceIntType) {
SpiceInt kernelValue;
gipool_c(key.toLatin1().data(), (SpiceInt)index, 1, &numValuesRead,
&kernelValue, &found);

if (found)
if (found && numValuesRead > 0)
result = (int)kernelValue;
}

if (!found) {
QString msg = "Can not find [" + key + "] in text kernels";
throw IException(IException::Io, msg, _FILEINFO_);
}
else if (numValuesRead == 0){
QString msg = "Found " + key + "] in text kernels, but no values were identified and read.";
throw IException(IException::Io, msg, _FILEINFO_);
}

storeValue(key, index, type, result);
NaifStatus::CheckErrors();
Expand Down

0 comments on commit cd667c8

Please sign in to comment.