backport from trunk (rev #9627):
-fixed crash in a debug printing - pattern may be NULL
 Reproted by Nathaniel L Keeling III