avoid NULL pointer dereference (coverity 1091332)
(cherry picked from commit 4325e1959457a6577cdbea56a49808e35499a9b1)