commit 6a1a73b2c0161bf7bd456df97c584b40827bbf7b
parent ba84ffade367374cc94abaad6409096e6abf733e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 23 Nov 2015 21:35:06 +0100
Fix issues in the parsing of histograms
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/schiff_args.c b/src/schiff_args.c
@@ -403,7 +403,7 @@ parse_super_formula(const char* str, struct schiff_param formula[6])
}
tk = strtok_r(str_get(&buf), ",", &tk_ctx);
- for(i=0; i < 6 && tk; ++i ) {
+ for(i=0; tk && i < 6; ++i ) {
res = parse_param_distribution(tk, formula + i);
if(res != RES_OK) goto error;
tk = strtok_r(NULL, ",", &tk_ctx);
diff --git a/src/schiff_histogram.c b/src/schiff_histogram.c
@@ -136,6 +136,7 @@ parse_histogram_header
fprintf(stderr, "%s:%lu: invalid number of histogram intervals `%s'.\n",
filename, (unsigned long)iline, tk);
if(res == RES_OK) res = RES_BAD_ARG;
+ goto error;
}
*size = (size_t)l;
@@ -220,9 +221,10 @@ schiff_histogram_load_stream
}
step = (bounds[1] - bounds[0])/(double)nentries;
+ ASSERT(step >= 0);
val = bounds[0];
accum_proba = 0;
- for(;(res = schiff_streamline_read(&streamline, stream, &line))!=RES_EOF
+ for(i=0;(res = schiff_streamline_read(&streamline, stream, &line))!=RES_EOF
&& i<nentries; ++iline) {
double proba;