fix undefined behavior in scanf core