@@ -2104,7 +2104,8 @@ CPLErr GDALSetGCPs2(GDALDatasetH hDS, int nGCPCount, const GDAL_GCP *pasGCPList,
2104
2104
* "BILINEAR", "CUBIC", "CUBICSPLINE", "GAUSS", "LANCZOS", "MODE", "NEAREST",
2105
2105
* or "NONE" controlling the downsampling method applied.
2106
2106
* @param nOverviews number of overviews to build, or 0 to clean overviews.
2107
- * @param panOverviewList the list of overview decimation factors to build, or
2107
+ * @param panOverviewList the list of overview decimation factors (positive
2108
+ * integers, normally larger or equal to 2) to build, or
2108
2109
* NULL if nOverviews == 0.
2109
2110
* @param nListBands number of bands to build overviews for in panBandList.
2110
2111
* Build for all bands if this is 0.
@@ -2151,6 +2152,18 @@ CPLErr GDALDataset::BuildOverviews(const char *pszResampling, int nOverviews,
2151
2152
if (pfnProgress == nullptr )
2152
2153
pfnProgress = GDALDummyProgress;
2153
2154
2155
+ for (int i = 0 ; i < nOverviews; ++i)
2156
+ {
2157
+ if (panOverviewList[i] <= 0 )
2158
+ {
2159
+ CPLError (CE_Failure, CPLE_IllegalArg,
2160
+ " panOverviewList[%d] = %d is invalid. It must be a "
2161
+ " positive value" ,
2162
+ i, panOverviewList[i]);
2163
+ return CE_Failure;
2164
+ }
2165
+ }
2166
+
2154
2167
// At time of writing, all overview generation options are actually
2155
2168
// expected to be passed as configuration options.
2156
2169
std::vector<std::unique_ptr<CPLConfigOptionSetter>> apoConfigOptionSetter;
0 commit comments