Robustness fix for WinAPIEventDriverWatchers.
Under certain (rare) circumstances, the receive buffer contains data from a file instead of the expected FILE_NOTIFY_INFORMATION structure. No signs of handle or buffer reuse could be found, so the cause for this remains unclear. Until the cause can be narrowed down, this keeps the issue visible while avoiding to crash the application.
This commit is contained in:
parent
fbd6927377
commit
3d2a2656bb
|
@ -127,6 +127,14 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
|
|||
while (result.length) {
|
||||
assert(result.length >= FILE_NOTIFY_INFORMATION._FileName.offsetof);
|
||||
auto fni = () @trusted { return cast(FILE_NOTIFY_INFORMATION*)result.ptr; } ();
|
||||
if (fni.NextEntryOffset > result.length) {
|
||||
import std.stdio : stderr;
|
||||
() @trusted {
|
||||
try stderr.writeln("ERROR: Invalid directory watcher event received.");
|
||||
catch (Exception e) {}
|
||||
} ();
|
||||
break;
|
||||
}
|
||||
result = result[fni.NextEntryOffset .. $];
|
||||
|
||||
FileChange ch;
|
||||
|
|
Loading…
Reference in a new issue