When copying filename it uses a static char array to store it. It is recommended to use heap. But that's not the real problem. You should use strncpy to safe copy the string. That saves you from stack overflow problems because it lets you specify the amount of chars to be copied. If you pass it more than that, it will only copy that amount and disregard the rest. I'm uploading a patch. I've not really tried it since I have dependency problems to recompile, sorry. But I think you won't have any problem with it.