check that the malloced memory is not null

should help with bug #9808