This function can be called with NULL arguments, so check that before passing to log_error. (cherry picked from commit e12b72440bcd79f109f14da1ba4c1757800d897c)