Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Bjarne Kvinge <rolf@xamarin.com>2020-10-01 19:49:57 +0300
committerMarek Safar <marek.safar@gmail.com>2020-10-01 20:34:12 +0300
commit1b3c820405a003b30f9aedf06d39def54040f4b0 (patch)
treee65a6124fb5f26c96daed7d968556396b98a0d03
parent26d148421cefd47aaeb5b1f408e6fc60e00d981b (diff)
Fix skipping null entries in the custom attribute table. Fixes #19.
The custom attribute table is sorted, but it may contain null entries, which should be skipped. Teach the BinarySearch algorithm to skip those null entries.
-rw-r--r--reflect/Metadata/Tables.cs12
1 files changed, 10 insertions, 2 deletions
diff --git a/reflect/Metadata/Tables.cs b/reflect/Metadata/Tables.cs
index 491c1ba1..d30cc42b 100644
--- a/reflect/Metadata/Tables.cs
+++ b/reflect/Metadata/Tables.cs
@@ -451,18 +451,19 @@ namespace IKVM.Reflection.Metadata
return new Enumerator(records, table.RowCount - 1, -1, token);
}
int index = BinarySearch(records, table.RowCount, token & 0xFFFFFF);
+
if (index < 0)
{
return new Enumerator(null, 0, 1, -1);
}
int start = index;
- while (start > 0 && (records[start - 1].FilterKey & 0xFFFFFF) == (token & 0xFFFFFF))
+ while (start > 0 && (((records [start - 1].FilterKey & 0xFFFFFF) == (token & 0xFFFFFF))) || ((records [start - 1].FilterKey & 0xFFFFFF) == 0))
{
start--;
}
int end = index;
int max = table.RowCount - 1;
- while (end < max && (records[end + 1].FilterKey & 0xFFFFFF) == (token & 0xFFFFFF))
+ while (end < max && (((records [end + 1].FilterKey & 0xFFFFFF) == (token & 0xFFFFFF))) || ((records [end + 1].FilterKey & 0xFFFFFF) == 0))
{
end++;
}
@@ -481,6 +482,13 @@ namespace IKVM.Reflection.Metadata
{
return mid;
}
+ else if (maskedValue == 0)
+ {
+ if (min > 0)
+ min--;
+ if (max < length - 1)
+ max++;
+ }
else if (maskedToken < maskedValue)
{
max = mid - 1;