opensmalltalk-vm
opensmalltalk-vm copied to clipboard
primitiveDirectoryLookup NULL access on Windows
The following code crashes the VM:
i:=0.
[ FileDirectory new primLookupEntryIn: 'C:' index: i] whileNotNil: [ i:= i+1].
FileDirectory new primLookupEntryIn: 'C:' index: i+1
The reason is that the dirCacheHit
path in sqWin32Directory.c
is taken and FindNextFileW
is called with findHandle == NULL
.
Additionally, primLookupEntryIn
accepts negative indices, which means this works but probably should not:
FileDirectory new primLookupEntryIn: 'C:' index: -1.
FileDirectory new primLookupEntryIn: 'C:' index: 0.
(FileDirectory new primLookupEntryIn: 'C:' index: 1) ~~(FileDirectory new primLookupEntryIn: 'C:' index: 1) "= true"