- Ptr = List;\r
- do {\r
- Ptr = Ptr->ForwardLink;\r
- Count--;\r
- } while ((Ptr != List) && (Ptr != Node) && (Count > 0));\r
- Found = (BOOLEAN)(Ptr == Node);\r
+ if (FeaturePcdGet (PcdVerifyNodeInList) && VerifyNodeInList) {\r
+ //\r
+ // Check to see if Node is a member of List. \r
+ // Exit early if the number of nodes in List >= PcdMaximumLinkedListLength\r
+ //\r
+ do {\r
+ Ptr = Ptr->ForwardLink;\r
+ if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {\r
+ Count++;\r
+ //\r
+ // ASSERT() if the linked list is too long\r
+ //\r
+ ASSERT (Count < PcdGet32 (PcdMaximumLinkedListLength));\r
+\r
+ //\r
+ // Return if the linked list is too long\r
+ //\r
+ if (Count >= PcdGet32 (PcdMaximumLinkedListLength)) {\r
+ return (BOOLEAN)(Ptr == Node);\r
+ }\r
+ }\r
+ } while ((Ptr != List) && (Ptr != Node)); \r
+\r
+ if (Ptr != Node) {\r
+ return FALSE;\r
+ }\r
+ }\r