From 0a6f3d8bfab4afb31136ffaa3ef9e16425db0b41 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 5 Mar 2014 11:33:31 +0000 Subject: [PATCH] Fix broken build (Windows Visual Studio) --- tools/grib_options.c | 2 ++ tools/grib_tools.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/grib_options.c b/tools/grib_options.c index 4237f8308..8a85a3610 100644 --- a/tools/grib_options.c +++ b/tools/grib_options.c @@ -220,8 +220,10 @@ int grib_process_runtime_options(grib_context* context,int argc,char** argv,grib if (grib_options_on("X:")) options->infile_offset=atol(grib_options_get_option("X:")); +#ifndef GRIB_ON_WINDOWS /* Check at compile time to ensure our file offset is at least 64 bits */ COMPILE_TIME_ASSERT( sizeof(options->infile_offset) >= 8 ); +#endif has_output=grib_options_on("U"); has_input_extra=grib_options_on("I"); diff --git a/tools/grib_tools.c b/tools/grib_tools.c index ce73feaf8..ade796dfb 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -288,9 +288,10 @@ static int grib_tool_without_orderby(grib_runtime_options* options) exit(1); } if (options->infile_offset) { +#ifndef GRIB_ON_WINDOWS /* Check at compile time to ensure our file offset is at least 64 bits */ COMPILE_TIME_ASSERT( sizeof(options->infile_offset) >= 8 ); - +#endif err=fseeko(infile->file, options->infile_offset, SEEK_SET); if (err) { /*fprintf(stderr, "Invalid file offset: %ld\n", options->infile_offset);*/ @@ -854,7 +855,7 @@ void grib_print_key_values(grib_runtime_options* options,grib_handle* h) double v=0; /*if (grib_get_double_element(h,"values",options->index,&v) != GRIB_SUCCESS) {*/ if (1) { - size_t size; + size_t size, the_index = 0; double* values; int err=0; @@ -866,6 +867,12 @@ void grib_print_key_values(grib_runtime_options* options,grib_handle* h) } values=grib_context_malloc_clear(h->context,size*sizeof(double)); grib_get_double_array(h,"values",values,&size); + the_index = options->index; + if (the_index >= size) { + fprintf(dump_file,"\n"); + fprintf(stderr, "invalid index value %d (should be between 0 and %ld)\n", options->index, size-1); + exit(1); + } v=values[options->index]; grib_context_free(h->context,values); }