fix bug free pointer in setpath function