From 91fb3f14d796a2294250febd4029f823b8e04ec8 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 6 Feb 2017 13:45:34 +0000 Subject: [PATCH] ECC-424: Do not allow non-BUFR messages for bufr_keys_iterator_new --- src/bufr_keys_iterator.c | 6 ++++++ src/grib_keys_iterator.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/bufr_keys_iterator.c b/src/bufr_keys_iterator.c index 7f2783e1a..f177ce15d 100644 --- a/src/bufr_keys_iterator.c +++ b/src/bufr_keys_iterator.c @@ -16,6 +16,12 @@ bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h) if (!h) return NULL; + if (h->product_kind != PRODUCT_BUFR) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "Invalid keys iterator for message: please use codes_keys_iterator_new"); + return NULL; + } + ki= (bufr_keys_iterator*)grib_context_malloc_clear(h->context,sizeof(bufr_keys_iterator)); if (!ki) return NULL; diff --git a/src/grib_keys_iterator.c b/src/grib_keys_iterator.c index b8818f9f3..d27b5bbf0 100644 --- a/src/grib_keys_iterator.c +++ b/src/grib_keys_iterator.c @@ -23,6 +23,12 @@ grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_f if (!h) return NULL; + /*if (h->product_kind == PRODUCT_BUFR) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "Invalid keys iterator for BUFR message: please use codes_bufr_keys_iterator_new"); + return NULL; + }*/ + ki= (grib_keys_iterator*)grib_context_malloc_clear(h->context,sizeof(grib_keys_iterator)); if (!ki) return NULL;