@@ -4150,16 +4150,20 @@ GDALDataset *GDALPDFCreateCopy(const char *pszFilename, GDALDataset *poSrcDS,
4150
4150
GDALProgressFunc pfnProgress,
4151
4151
void *pProgressData)
4152
4152
{
4153
- int nBands = poSrcDS->GetRasterCount ();
4154
- int nWidth = poSrcDS->GetRasterXSize ();
4155
- int nHeight = poSrcDS->GetRasterYSize ();
4156
-
4157
- if (!pfnProgress (0.0 , nullptr , pProgressData))
4158
- return nullptr ;
4153
+ const int nBands = poSrcDS->GetRasterCount ();
4154
+ const int nWidth = poSrcDS->GetRasterXSize ();
4155
+ const int nHeight = poSrcDS->GetRasterYSize ();
4159
4156
4160
4157
/* -------------------------------------------------------------------- */
4161
4158
/* Some some rudimentary checks */
4162
4159
/* -------------------------------------------------------------------- */
4160
+ if (nWidth == 0 || nHeight == 0 )
4161
+ {
4162
+ CPLError (CE_Failure, CPLE_NotSupported,
4163
+ " nWidth == 0 || nHeight == 0 not supported" );
4164
+ return nullptr ;
4165
+ }
4166
+
4163
4167
if (nBands != 1 && nBands != 3 && nBands != 4 )
4164
4168
{
4165
4169
CPLError (CE_Failure, CPLE_NotSupported,
@@ -4491,6 +4495,9 @@ GDALDataset *GDALPDFCreateCopy(const char *pszFilename, GDALDataset *poSrcDS,
4491
4495
const char *pszJavascriptFile =
4492
4496
CSLFetchNameValue (papszOptions, " JAVASCRIPT_FILE" );
4493
4497
4498
+ if (!pfnProgress (0.0 , nullptr , pProgressData))
4499
+ return nullptr ;
4500
+
4494
4501
/* -------------------------------------------------------------------- */
4495
4502
/* Create file. */
4496
4503
/* -------------------------------------------------------------------- */
0 commit comments