fix memory issue (static analyzer warning, potential null deref).