ECC-210: ecCodes Segmentation fault with DWD BUFR-encoded synop data (part 2)

This commit is contained in:
Shahram Najm 2016-05-16 13:30:06 +01:00
parent 79a0e36b07
commit 452d79e08e
1 changed files with 25 additions and 20 deletions

View File

@ -18,8 +18,8 @@
grib_option grib_options[]={
/* {id, args, help}, on, command_line, value*/
{"j:","s/f/a","\n\t\tJSON mode (JavaScript Object Notation)."
"\n\t\tOptions: s->structure, f->flat (only data), a->all attributes"
"\n\t\tDefault mode is structure.\n",
"\n\t\tOptions: s->structure, f->flat (only data), a->all attributes"
"\n\t\tDefault mode is structure.\n",
1,1,"s"},
{"S",0,0,1,0,0},
{"O",0,"Octet mode. WMO documentation style dump.\n",0,1,0},
@ -80,8 +80,8 @@ int grib_tool_init(grib_runtime_options* options)
options->dump_mode = "json";
json_option=grib_options_get_option("j:");
if (strlen(json_option)>1 || ( json_option[0] != 's' && json_option[0]!= 'f' && json_option[0]!= 'a')) {
printf("wrong json option %s\n",json_option);
exit(1);
printf("wrong json option %s\n",json_option);
exit(1);
}
json=1;
}
@ -165,42 +165,42 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
if (json) {
if (options->handle_count>1) fprintf(stdout,",\n");
if (json && first_handle) {
fprintf(stdout,"{ \"messages\" : [ \n");
first_handle=0;
fprintf(stdout,"{ \"messages\" : [ \n");
first_handle=0;
}
switch (json_option[0]) {
case 'f':
case 'f':
err=grib_set_long(h,"unpack",2);
if (err) {
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
}
a=grib_find_accessor(h,"numericValues");
al=accessor_bufr_data_array_get_dataAccessors(a);
options->dump_flags=GRIB_DUMP_FLAG_ALL_ATTRIBUTES;
codes_dump_bufr_flat(al,h,stdout,options->dump_mode,options->dump_flags,0);
break;
case 's':
case 's':
err=grib_set_long(h,"unpack",1);
if (err) {
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
}
grib_dump_content(h,stdout,options->dump_mode,options->dump_flags,0);
break;
case 'a':
case 'a':
err=grib_set_long(h,"unpack",1);
if (err) {
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
}
options->dump_flags=GRIB_DUMP_FLAG_ALL_ATTRIBUTES;
grib_dump_content(h,stdout,options->dump_mode,options->dump_flags,0);
break;
default :
default :
printf("unknown json option %s\n",json_option);
exit(1);
}
@ -208,7 +208,12 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
sprintf(tmp,"MESSAGE %d ( length=%ld )",options->handle_count,length);
if (!grib_options_on("C"))
fprintf(stdout,"#============== %-38s ==============\n",tmp);
grib_set_long(h,"unpack",1);
err=grib_set_long(h,"unpack",1);
if (err) {
fprintf(stdout,"\"ERROR: unable to unpack data section\"");
options->error=err;
return err;
}
grib_dump_content(h,stdout,options->dump_mode,options->dump_flags,0);
}