@@ -1390,7 +1390,8 @@ ReadLabelStorageArea(
13901390 if ((* ppLsa )-> Index [CurrentIndex ].pFree [LABELS_TO_FREE_BYTES (AlignPageIndex )] != FREE_BLOCKS_MASK_ALL_SET ) {
13911391 // Find the label to read
13921392 for (PageIndexMask = (* ppLsa )-> Index [CurrentIndex ].pFree [LABELS_TO_FREE_BYTES (AlignPageIndex )], Index = 0 ;
1393- Index < NSINDEX_FREE_ALIGN ; PageIndexMask >>= 1 , Index ++ ) {
1393+ (Index < NSINDEX_FREE_ALIGN ) && ((AlignPageIndex + Index ) < (* ppLsa )-> Index [CurrentIndex ].NumberOfLabels );
1394+ PageIndexMask >>= 1 , Index ++ ) {
13941395 if (BIT0 != (PageIndexMask & BIT0 )) {
13951396 // Calculate the offest to read, one label per read only
13961397 Offset = (UINT32 )(LabelIndexSize + (PageSize * (AlignPageIndex + Index )));
@@ -1536,7 +1537,8 @@ WriteLabelStorageArea(
15361537 if (pLsa -> Index [CurrentIndex ].pFree [LABELS_TO_FREE_BYTES (AlignPageIndex )] != FREE_BLOCKS_MASK_ALL_SET ) {
15371538 // Find the label to write
15381539 for (PageIndexMask = pLsa -> Index [CurrentIndex ].pFree [LABELS_TO_FREE_BYTES (AlignPageIndex )], Index = 0 ;
1539- Index < NSINDEX_FREE_ALIGN ; PageIndexMask >>= 1 , Index ++ ) {
1540+ (Index < NSINDEX_FREE_ALIGN ) && ((AlignPageIndex + Index ) < pLsa -> Index [CurrentIndex ].NumberOfLabels );
1541+ PageIndexMask >>= 1 , Index ++ ) {
15401542 if (BIT0 != (PageIndexMask & BIT0 )) {
15411543 // Calculate the offset to write, one label per write only
15421544 pFrom = ((UINT8 * )(pLsa -> pLabels ) + (sizeof (NAMESPACE_LABEL ) * (AlignPageIndex + Index )));
0 commit comments