Fix crash on CONNECTIONTYPE kerneldensity on Windows (#5019)