Bogus check. You probably meant `buf == NULL`?