Fix stack smashing error