bugfix: check whether return from malloc is NULL
bugfix: check whether return from malloc is NULL

emilcondrea/trousers,Distrotech/trousers,emilcondrea/trousers,Distrotech/trousers,Distrotech/trousers,emilcondrea/trousers