fix memory access violation bug. it occurs when built with Release configuration