ECC-532 and ECC-492: bufr_dump memory (for decode too)

This commit is contained in:
Shahram Najm 2017-08-24 19:06:40 +01:00
parent 7301b56bb0
commit 9a8e0ead03
4 changed files with 53 additions and 50 deletions

View File

@ -162,12 +162,12 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_double(a,&value,&size);
}
@ -222,18 +222,18 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_bufr_decode_C *self = (grib_dumper_bufr_decode_C*)d;
double value; size_t size = 0;
double value=0; size_t size = 0;
int err = 0;
long count=0;
char* sval;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_double(a,&value,&size);
}
@ -287,11 +287,12 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 )
return;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf==0) {
char* prefix;
@ -366,12 +367,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
long count=0;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_long(a,&value,&size);
}
@ -423,10 +424,10 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
grib_handle* h=grib_handle_of_accessor(a);
grib_context* c=h->context;
grib_unpack_double(a,&value,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_unpack_double(a,&value,&size);
self->empty=0;
r=compute_bufr_key_rank(h,self->keys,a->name);
@ -459,7 +460,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_C *self = (grib_dumper_bufr_decode_C*)d;
char **values;
char **values = NULL;
size_t size = 0;
grib_context* c=NULL;
int err = 0;

View File

@ -145,19 +145,19 @@ static int destroy(grib_dumper* d)
static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_decode_filter *self = (grib_dumper_bufr_decode_filter*)d;
double value; size_t size = 0;
double value=0; size_t size = 0;
int err = 0;
int r;
long count=0;
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size<=1) {
err=grib_unpack_double(a,&value,&size);
}
@ -203,17 +203,17 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* prefix)
{
grib_dumper_bufr_decode_filter *self = (grib_dumper_bufr_decode_filter*)d;
double value; size_t size = 0;
double value=0; size_t size = 0;
int err = 0;
long count=0;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size<=1) {
err=grib_unpack_double(a,&value,&size);
}
@ -251,11 +251,11 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf==0) {
char* prefix;
@ -346,15 +346,15 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_filter *self = (grib_dumper_bufr_decode_filter*)d;
double value; size_t size = 1;
double value=0; size_t size = 1;
int r;
grib_handle* h=grib_handle_of_accessor(a);
grib_context* c=h->context;
grib_unpack_double(a,&value,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_unpack_double(a,&value,&size);
self->begin=0;
self->empty=0;

View File

@ -154,12 +154,12 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size<=1) {
err=grib_unpack_double(a,&value,&size);
}
@ -209,12 +209,12 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
long count=0;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_double(a,&value,&size);
}
@ -254,11 +254,12 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 )
return;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf==0) {
char* prefix;
@ -328,12 +329,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
long count=0;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_long(a,&value,&size);
}
@ -378,10 +379,10 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
grib_handle* h=grib_handle_of_accessor(a);
grib_context* c=h->context;
grib_unpack_double(a,&value,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_unpack_double(a,&value,&size);
self->empty=0;
r=compute_bufr_key_rank(h,self->keys,a->name);

View File

@ -162,12 +162,12 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_double(a,&value,&size);
}
@ -221,12 +221,12 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p
char* sval;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) !=0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_double(a,&value,&size);
}
@ -272,11 +272,12 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 )
return;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf==0) {
char* prefix;
@ -344,12 +345,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
long count=0;
grib_context* c=a->context;
grib_value_count(a,&count);
size=count;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_value_count(a,&count);
size=count;
if (size <= 1) {
err=grib_unpack_long(a,&value,&size);
}
@ -392,10 +393,10 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
grib_handle* h=grib_handle_of_accessor(a);
grib_context* c=h->context;
grib_unpack_double(a,&value,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
grib_unpack_double(a,&value,&size);
self->empty=0;
r=compute_bufr_key_rank(h,self->keys,a->name);