gdalinfo: fix bound checking for value of -sds argument
This commit is contained in:
parent
5a7aac3e76
commit
b2f16324e8
|
@ -194,6 +194,7 @@ MAIN_START(argc, argv)
|
|||
else
|
||||
{
|
||||
char **papszSubdatasets = GDALGetMetadata(hDataset, "SUBDATASETS");
|
||||
const int nSubdatasets = CSLCount(papszSubdatasets) / 2;
|
||||
char *pszSubDest = static_cast<char *>(
|
||||
CPLMalloc(strlen(sOptionsForBinary.osDest.c_str()) + 32));
|
||||
|
||||
|
@ -205,11 +206,11 @@ MAIN_START(argc, argv)
|
|||
CPLString osTemp;
|
||||
|
||||
const char *pszFormat = nullptr;
|
||||
if (CSLCount(papszSubdatasets) / 2 < 10)
|
||||
if (nSubdatasets < 10)
|
||||
{
|
||||
pszFormat = "%s_%d";
|
||||
}
|
||||
else if (CSLCount(papszSubdatasets) / 2 < 100)
|
||||
else if (nSubdatasets < 100)
|
||||
{
|
||||
pszFormat = "%s_%002d";
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ MAIN_START(argc, argv)
|
|||
if (sOptionsForBinary.nSubdataset > 0)
|
||||
{
|
||||
char **papszSubdatasets = GDALGetMetadata(hDataset, "SUBDATASETS");
|
||||
int nSubdatasets = CSLCount(papszSubdatasets);
|
||||
const int nSubdatasets = CSLCount(papszSubdatasets) / 2;
|
||||
|
||||
if (nSubdatasets > 0 &&
|
||||
sOptionsForBinary.nSubdataset <= nSubdatasets)
|
||||
|
|
Loading…
Reference in New Issue