From bc34a84eab410b82a14e181da3eec598309e7312 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 22 Feb 2022 17:07:54 +0100 Subject: [PATCH] proj_grid_info(): check pj_find_file() output (CID 383357) --- src/4D_api.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 9445839801..a7baaf93ea 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -2276,24 +2276,25 @@ PJ_GRID_INFO proj_grid_info(const char *gridname) { strncpy (grinfo.gridname, gridname, sizeof(grinfo.gridname) - 1); /* full path of grid */ - pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1); - - /* grid format */ - strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1); - - /* grid size */ - grinfo.n_lon = grid.width(); - grinfo.n_lat = grid.height(); - - /* cell size */ - grinfo.cs_lon = extent.resX; - grinfo.cs_lat = extent.resY; - - /* bounds of grid */ - grinfo.lowerleft.lam = extent.west; - grinfo.lowerleft.phi = extent.south; - grinfo.upperright.lam = extent.east; - grinfo.upperright.phi = extent.north; + if( pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1) ) + { + /* grid format */ + strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1); + + /* grid size */ + grinfo.n_lon = grid.width(); + grinfo.n_lat = grid.height(); + + /* cell size */ + grinfo.cs_lon = extent.resX; + grinfo.cs_lat = extent.resY; + + /* bounds of grid */ + grinfo.lowerleft.lam = extent.west; + grinfo.lowerleft.phi = extent.south; + grinfo.upperright.lam = extent.east; + grinfo.upperright.phi = extent.north; + } }; {