fix issue where filename length was set after malloc'ing it