malloc bug fixed