The ```xstrdup()``` call will segfault if it happens and the ```key``` is not null terminated. Same goes with code reading the value out of the StringMap later, it will segfault if ```val``` is not null terminated.

I'd suggest to at least check this and skip the key-value pair if that's the case, printing a verbose message.