Several struct members were left uninitialized in some paths of the
code. Fix this by initializing all struct members to 0 in the affected
places.
Also fix an incorrectly sized malloc, where the size of a pointer
instead of the struct size was supplied to malloc.