Check some mallocs

Fixes #1337.