From c6cf442abd4f02012bc5721c420ac01e4ca26f7e Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 2 Apr 2010 17:26:17 -0400 Subject: [PATCH] Fixed crash when ALG (algorithm) was changed to Average at runtime. (Fixes #552803) --- src/rec/compressRecord.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rec/compressRecord.c b/src/rec/compressRecord.c index bb265a82d..5d29f7ec0 100644 --- a/src/rec/compressRecord.c +++ b/src/rec/compressRecord.c @@ -80,10 +80,14 @@ epicsExportAddress(rset,compressRSET); static void reset(compressRecord *prec) { prec->nuse = 0; - prec->off= 0; + prec->off = 0; prec->inx = 0; prec->cvb = 0.0; prec->res = 0; + /* allocate memory for the summing buffer for conversions requiring it */ + if (prec->alg == compressALG_Average && prec->sptr == 0){ + prec->sptr = (double *)calloc(prec->nsam,sizeof(double)); + } } static void monitor(compressRecord *prec) @@ -292,10 +296,6 @@ static long init_record(compressRecord *prec, int pass) if (pass==0){ if(prec->nsam<1) prec->nsam = 1; prec->bptr = (double *)calloc(prec->nsam,sizeof(double)); - /* allocate memory for the summing buffer for conversions requiring it */ - if (prec->alg == compressALG_Average){ - prec->sptr = (double *)calloc(prec->nsam,sizeof(double)); - } reset(prec); } return(0);