Getting weird behavior in if statement.

From the above link:

The caller is responsible for providing sufficient storage in s.