diff --git a/src/grib_nearest.c b/src/grib_nearest.c index f2d6a4aff..40bb5b1ef 100644 --- a/src/grib_nearest.c +++ b/src/grib_nearest.c @@ -23,7 +23,9 @@ int grib_nearest_find( double* outlats,double* outlons, double* values, double* distances, int* indexes, size_t *len) { - grib_nearest_class *c = nearest->cclass; + grib_nearest_class *c = NULL; + Assert(nearest); + c = nearest->cclass; Assert( flags <= (GRIB_NEAREST_SAME_GRID|GRIB_NEAREST_SAME_DATA|GRIB_NEAREST_SAME_POINT) ); while(c) @@ -73,7 +75,9 @@ int grib_nearest_init(grib_nearest* i, grib_handle *h, grib_arguments* args) int grib_nearest_delete(grib_nearest *i) { - grib_nearest_class *c = i->cclass; + grib_nearest_class *c = NULL; + Assert(i); + c = i->cclass; while(c) { grib_nearest_class *s = c->super ? *(c->super) : NULL;