Post your updated code. It's probably related to how you malloc space for path or how you call this.