mirror of https://github.com/ecmwf/eccodes.git
GRIB-932: Crash: using keys iterator with skip duplicates
This commit is contained in:
parent
1684f93b3c
commit
583a6296d3
|
@ -37,7 +37,8 @@ int main(int argc, char *argv[])
|
|||
unsigned long key_iterator_filter_flags=CODES_KEYS_ITERATOR_SKIP_READ_ONLY |
|
||||
CODES_KEYS_ITERATOR_SKIP_COMPUTED;
|
||||
*/
|
||||
unsigned long key_iterator_filter_flags=CODES_KEYS_ITERATOR_ALL_KEYS;
|
||||
unsigned long key_iterator_filter_flags = CODES_KEYS_ITERATOR_ALL_KEYS |
|
||||
CODES_KEYS_ITERATOR_SKIP_DUPLICATES;
|
||||
|
||||
/* Choose a namespace. E.g. "ls", "time", "parameter", "geography", "statistics" */
|
||||
char* name_space="ls";
|
||||
|
|
|
@ -13,3 +13,4 @@ ${examples_dir}c_grib_keys_iterator ${data_dir}/reduced_latlon_surface.grib1 > /
|
|||
|
||||
${examples_dir}c_grib_keys_iterator ${data_dir}/regular_gaussian_model_level.grib1 > /dev/null
|
||||
|
||||
${examples_dir}c_grib_keys_iterator ${data_dir}/mixed.grib > /dev/null
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/*
|
||||
* C Implementation: grib_keys_iterator
|
||||
*
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
GRIB_INLINE static int grib_inline_strcmp(const char* a,const char* b)
|
||||
|
@ -33,7 +28,7 @@ struct grib_keys_iterator{
|
|||
grib_trie *seen;
|
||||
};
|
||||
|
||||
grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_flags, const char* name_space)
|
||||
grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_flags, const char* name_space)
|
||||
{
|
||||
grib_keys_iterator* ki=NULL;
|
||||
|
||||
|
@ -88,7 +83,11 @@ int grib_keys_iterator_set_flags(grib_keys_iterator* ki,unsigned long flags)
|
|||
|
||||
static void mark_seen(grib_keys_iterator* ki,const char* name)
|
||||
{
|
||||
grib_trie_insert(ki->seen,name,(void*)name);
|
||||
/* See GRIB-932 */
|
||||
char* tmp = grib_context_strdup(ki->handle->context, name);
|
||||
grib_trie_insert(ki->seen, tmp,(void*)tmp);
|
||||
|
||||
/* grib_trie_insert(ki->seen,name,(void*)name); */
|
||||
}
|
||||
|
||||
static int was_seen(grib_keys_iterator* ki,const char* name)
|
||||
|
|
Loading…
Reference in New Issue