fix null-reference bug found by STACK