浏览代码

attempted fix for BUG2

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43874 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 14 年之前
父节点
当前提交
740bb9a03a
共有 1 个文件被更改,包括 16 次插入3 次删除
  1. 16 3
      lib/vector/dglib/sp-template.c

+ 16 - 3
lib/vector/dglib/sp-template.c

@@ -70,6 +70,7 @@ static int DGL_SP_CACHE_DISTANCE_FUNC(dglGraph_s * pgraph,
 				      dglInt32_t nStart,
 				      dglInt32_t nDestination)
 {
+    dglTreeTouchI32_s VisitedItem;
     dglTreePredist_s *pPredistItem, PredistItem;
 
     if (pCache->nStartNode != nStart) {
@@ -77,9 +78,15 @@ static int DGL_SP_CACHE_DISTANCE_FUNC(dglGraph_s * pgraph,
 	return -pgraph->iErrno;
     }
 
+    VisitedItem.nKey = nDestination;
+    if (avl_find(pCache->pvVisited, &VisitedItem) == NULL) {
+	pgraph->iErrno = DGL_ERR_TailNodeNotFound;
+	return -pgraph->iErrno;
+    }
+
     PredistItem.nKey = nDestination;
     if ((pPredistItem = avl_find(pCache->pvPredist, &PredistItem)) == NULL) {
-	pgraph->iErrno = DGL_ERR_TailNodeNotFound;
+	pgraph->iErrno = DGL_ERR_UnexpectedNullPointer;
 	return -pgraph->iErrno;
     }
 
@@ -93,6 +100,7 @@ static dglSPReport_s *DGL_SP_CACHE_REPORT_FUNC(dglGraph_s * pgraph,
 					       dglInt32_t nStart,
 					       dglInt32_t nDestination)
 {
+    dglTreeTouchI32_s VisitedItem;
     dglTreePredist_s *pPredistItem, PredistItem;
     dglInt32_t *pEdge;
     dglInt32_t *pDestination;
@@ -107,10 +115,15 @@ static dglSPReport_s *DGL_SP_CACHE_REPORT_FUNC(dglGraph_s * pgraph,
 	return NULL;
     }
 
-    PredistItem.nKey = nDestination;
+    VisitedItem.nKey = nDestination;
+    if (avl_find(pCache->pvVisited, &VisitedItem) == NULL) {
+	pgraph->iErrno = DGL_ERR_TailNodeNotFound;
+	return NULL;
+    }
 
+    PredistItem.nKey = nDestination;
     if (avl_find(pCache->pvPredist, &PredistItem) == NULL) {
-	pgraph->iErrno = DGL_ERR_TailNodeNotFound;
+	pgraph->iErrno = DGL_ERR_UnexpectedNullPointer;
 	return NULL;
     }