fix bug: malloc corruption