From 99ba37ba58b2d0bbd6dc3b8bdaabf4d40c449d97 Mon Sep 17 00:00:00 2001 From: Alexander Barth Date: Thu, 8 Aug 2024 10:10:55 +0200 Subject: [PATCH] Take into account that attach_dimscales can fail when dimensions and variables are named inconsistently (Unidata/netcdf-c#2962) --- libhdf5/nc4hdf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libhdf5/nc4hdf.c b/libhdf5/nc4hdf.c index 105d5880fb..bb2de5bf64 100644 --- a/libhdf5/nc4hdf.c +++ b/libhdf5/nc4hdf.c @@ -1449,7 +1449,9 @@ attach_dimscales(NC_GRP_INFO_T *grp) dsid = ((NC_HDF5_VAR_INFO_T *)(var->dim[d]->coord_var->format_var_info))->hdf_datasetid; else dsid = ((NC_HDF5_DIM_INFO_T *)var->dim[d]->format_dim_info)->hdf_dimscaleid; - assert(dsid > 0); + + if (dsid <= 0) + return NC_EDIMSCALE; /* Attach the scale. */ if (H5DSattach_scale(hdf5_var->hdf_datasetid, dsid, d) < 0)