Krzysztof Kowalczyk's fix for "Assertion failed: actuallen <= len" when