malloc the char buffer because size is not constant

Issue #356