Skip to content

Commit

Permalink
added range check to readBlobHeapUncached
Browse files Browse the repository at this point in the history
  • Loading branch information
vladima committed Jun 29, 2015
1 parent 7e2a0db commit 0c0c696
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/absil/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ type ILReaderContext =
userStringsStreamPhysicalLoc: int32;
stringsStreamPhysicalLoc: int32;
blobsStreamPhysicalLoc: int32;
blobsStreamSize: int32;
readUserStringHeap: (int32 -> string);
memoizeString: string -> string;
readStringHeap: (int32 -> string);
Expand Down Expand Up @@ -1533,9 +1534,11 @@ let readStringHeapUncached ctxtH idx =
let readStringHeap ctxt idx = ctxt.readStringHeap idx
let readStringHeapOption ctxt idx = if idx = 0 then None else Some (readStringHeap ctxt idx)

let emptyByteArray: byte[] = [||]
let readBlobHeapUncached ctxtH idx =
let ctxt = getHole ctxtH
seekReadBlob ctxt.is (ctxt.blobsStreamPhysicalLoc + idx)
if idx < 0 || idx > ctxt.blobsStreamSize then emptyByteArray
else seekReadBlob ctxt.is (ctxt.blobsStreamPhysicalLoc + idx)
let readBlobHeap ctxt idx = ctxt.readBlobHeap idx
let readBlobHeapOption ctxt idx = if idx = 0 then None else Some (readBlobHeap ctxt idx)

Expand Down Expand Up @@ -3971,6 +3974,7 @@ let rec genOpenBinaryReader infile is opts =
userStringsStreamPhysicalLoc = userStringsStreamPhysicalLoc;
stringsStreamPhysicalLoc = stringsStreamPhysicalLoc;
blobsStreamPhysicalLoc = blobsStreamPhysicalLoc;
blobsStreamSize = blobsStreamSize;
memoizeString = Tables.memoize id;
readUserStringHeap = cacheUserStringHeap (readUserStringHeapUncached ctxtH);
readStringHeap = cacheStringHeap (readStringHeapUncached ctxtH);
Expand Down

0 comments on commit 0c0c696

Please sign in to comment.