issue #2087: Fixing potential crash reported by Sam Gross. Thanks @Sam.