[1.5.x] Fixed #19632 -- Bug in code sample.

Thanks grossmanandy at bfusa com and Simon Charette.

Backport of 1dd7492.