fixing bug. int overflow in mallocs