Check mallocs
Fix a wrong return type