Skip to content

HashSetFn.isSubset function accesses out of bound element#310

Merged
JohnReppy merged 1 commit intosmlnj:mainfrom
zbyrn:main
Apr 25, 2024
Merged

HashSetFn.isSubset function accesses out of bound element#310
JohnReppy merged 1 commit intosmlnj:mainfrom
zbyrn:main

Conversation

@zbyrn
Copy link
Copy Markdown
Contributor

@zbyrn zbyrn commented Apr 24, 2024

structure IntHashSet = HashSetFn(IntHashTable.Key)

val set1 = IntHashSet.mkFromList [1]
val set2 = IntHashSet.mkFromList [1]

val chk = IntHashSet.isSubset (set1, set2)

Running the above code snippet results in the following exception:

Standard ML of New Jersey (64-bit) v110.99.5 [built: Thu Mar 14 17:56:03 2024]
[opening subset.sml]
[autoloading]
[library $SMLNJ-LIB/Util/smlnj-lib.cm is stable]
[autoloading done]

uncaught exception Subscript [subscript out of bounds]
  raised at: ../../smlnj-lib/Util/hash-set-fn.sml:208.32-208.41

Description

The highest index in an array of length n is n - 1; however, the isSubset function uses i <= sz to test the end of the array.

@JohnReppy JohnReppy changed the title HashSetFn isSubset function accesses out of bound element HashSetFn.isSubset function accesses out of bound element Apr 25, 2024
@JohnReppy JohnReppy added smlnj-lib General issue with the SML/NJ Library or the Util component fixed-in-110.99.6 issues that will be fixed in the 110.99.6 version labels Apr 25, 2024
@JohnReppy JohnReppy merged commit 403b8c3 into smlnj:main Apr 25, 2024
JohnReppy added a commit that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixed-in-110.99.6 issues that will be fixed in the 110.99.6 version smlnj-lib General issue with the SML/NJ Library or the Util component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants