Merge from 4.2-dev for TRQ-1988: valgrind found an invalid write.