diff --git a/src/rec/seqRecord.c b/src/rec/seqRecord.c index 7627f44e3..9d20726c0 100644 --- a/src/rec/seqRecord.c +++ b/src/rec/seqRecord.c @@ -174,6 +174,7 @@ static long process(seqRecord *prec) linkDesc *plink; unsigned short lmask; int tmp; + int index; if(seqRecDebug > 10) printf("seqRecord: process(%s) pact = %d\n", prec->name, prec->pact); @@ -230,6 +231,7 @@ static long process(seqRecord *prec) } /* Figure out which links are going to be processed */ pcb->index = 0; + index = 0; plink = (linkDesc *)(&(prec->dly1)); tmp = 1; while (lmask) @@ -241,23 +243,21 @@ static long process(seqRecord *prec) if ((lmask & 1) && ((plink->lnk.type != CONSTANT)||(plink->dol.type != CONSTANT))) { if (seqRecDebug > 4) - printf(" seqRec-process Adding link %d at index %d\n", tmp, pcb->index); + printf(" seqRec-process Adding link %d at index %d\n", tmp, index); - pcb->plinks[pcb->index] = plink; - pcb->index++; + pcb->plinks[index++] = plink; } lmask >>= 1; plink++; tmp++; } - pcb->plinks[pcb->index] = NULL; /* mark the bottom of the list */ + pcb->plinks[index] = NULL; /* mark the bottom of the list */ - if (!pcb->index) + if (!index) { /* There was nothing to do, finish record processing here */ return(asyncFinish(prec)); } - pcb->index = 0; /* Start doing the first forward link (We have at least one for sure) */ processNextLink(prec); @@ -367,6 +367,14 @@ static void processCallback(CALLBACK *arg) if (seqRecDebug > 5) printf("processCallback(%s) processing field index %d\n", prec->name, pcb->index+1); + if (pcb->plinks[pcb->index] == NULL) + { + static int overrun = 0; + errlogPrintf("seq record %s: index overrun number %d in callback.\n", prec->name, ++overrun); + dbScanUnlock((struct dbCommon *)prec); + return; + } + /* Save the old value */ myDouble = pcb->plinks[pcb->index]->dov;