For performance reasons, malloc() makes no guarantee regarding the contents of newly allocated memory. It might be zeros, it might be random data, it might be anything. If you want malloc'ed memory to have a specific value, then it is up to you do it.