Fix restore offset

Summary: Prevent OutOfBound Exception by checking
array size.