Fossil SCM

Fix a potential sigfault that can occur in the graph generator if the child is older than its parent.

drh 2010-08-24 01:24 trunk
Commit 7503f9877998135ead928a96125bf322dc794b56
1 file changed +3 -2
+3 -2
--- src/graph.c
+++ src/graph.c
@@ -242,11 +242,11 @@
242242
assert( pPrior->idx > pCurrent->idx );
243243
assert( pCurrent->iRail<0 );
244244
pCurrent->iRail = iRail;
245245
pCurrent->railInUse |= mask;
246246
pPrior->aiRaiser[iRail] = pCurrent->idx;
247
- while( pPrior!=pCurrent ){
247
+ while( pPrior->idx > pCurrent->idx ){
248248
pPrior->railInUse |= mask;
249249
pPrior = pPrior->pPrev;
250250
assert( pPrior!=0 );
251251
}
252252
if( pCurrent->pPrev ){
@@ -314,10 +314,11 @@
314314
if( pRow->isDup ) continue;
315315
if( pRow->nParent==0 ) continue;
316316
pParent = hashFind(p, pRow->aParent[0]);
317317
if( pParent==0 ) continue;
318318
if( pParent->zBranch!=pRow->zBranch ) continue;
319
+ if( pParent->idx <= pRow->idx ) continue;
319320
if( pRow->idxTop < pParent->idxTop ){
320321
pParent->pChild = pRow;
321322
pParent->idxTop = pRow->idxTop;
322323
}
323324
}
@@ -390,11 +391,11 @@
390391
}else{
391392
inUse |= mask;
392393
assignChildrenToRail(pRow);
393394
}
394395
if( pParent ){
395
- for(pLoop=pParent; pLoop!=pRow; pLoop=pLoop->pPrev){
396
+ for(pLoop=pParent; pLoop && pLoop!=pRow; pLoop=pLoop->pPrev){
396397
pLoop->railInUse |= mask;
397398
}
398399
}
399400
}
400401
401402
--- src/graph.c
+++ src/graph.c
@@ -242,11 +242,11 @@
242 assert( pPrior->idx > pCurrent->idx );
243 assert( pCurrent->iRail<0 );
244 pCurrent->iRail = iRail;
245 pCurrent->railInUse |= mask;
246 pPrior->aiRaiser[iRail] = pCurrent->idx;
247 while( pPrior!=pCurrent ){
248 pPrior->railInUse |= mask;
249 pPrior = pPrior->pPrev;
250 assert( pPrior!=0 );
251 }
252 if( pCurrent->pPrev ){
@@ -314,10 +314,11 @@
314 if( pRow->isDup ) continue;
315 if( pRow->nParent==0 ) continue;
316 pParent = hashFind(p, pRow->aParent[0]);
317 if( pParent==0 ) continue;
318 if( pParent->zBranch!=pRow->zBranch ) continue;
 
319 if( pRow->idxTop < pParent->idxTop ){
320 pParent->pChild = pRow;
321 pParent->idxTop = pRow->idxTop;
322 }
323 }
@@ -390,11 +391,11 @@
390 }else{
391 inUse |= mask;
392 assignChildrenToRail(pRow);
393 }
394 if( pParent ){
395 for(pLoop=pParent; pLoop!=pRow; pLoop=pLoop->pPrev){
396 pLoop->railInUse |= mask;
397 }
398 }
399 }
400
401
--- src/graph.c
+++ src/graph.c
@@ -242,11 +242,11 @@
242 assert( pPrior->idx > pCurrent->idx );
243 assert( pCurrent->iRail<0 );
244 pCurrent->iRail = iRail;
245 pCurrent->railInUse |= mask;
246 pPrior->aiRaiser[iRail] = pCurrent->idx;
247 while( pPrior->idx > pCurrent->idx ){
248 pPrior->railInUse |= mask;
249 pPrior = pPrior->pPrev;
250 assert( pPrior!=0 );
251 }
252 if( pCurrent->pPrev ){
@@ -314,10 +314,11 @@
314 if( pRow->isDup ) continue;
315 if( pRow->nParent==0 ) continue;
316 pParent = hashFind(p, pRow->aParent[0]);
317 if( pParent==0 ) continue;
318 if( pParent->zBranch!=pRow->zBranch ) continue;
319 if( pParent->idx <= pRow->idx ) continue;
320 if( pRow->idxTop < pParent->idxTop ){
321 pParent->pChild = pRow;
322 pParent->idxTop = pRow->idxTop;
323 }
324 }
@@ -390,11 +391,11 @@
391 }else{
392 inUse |= mask;
393 assignChildrenToRail(pRow);
394 }
395 if( pParent ){
396 for(pLoop=pParent; pLoop && pLoop!=pRow; pLoop=pLoop->pPrev){
397 pLoop->railInUse |= mask;
398 }
399 }
400 }
401
402

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button