ValueTree::fromXml crash

Maybe I’m missing something simple here.

I have a bunch of save routines that make use of the createXml and fromXml methods in the Valuetrees.

All well and good, except that once in a while one of these Xml files get’s corrupted (a bad download, or a user restarting the computer at the exact wrong time, etc).

When this happens, I notice that a crash is caused on fromXml().

Now, I know it says in the docs that this isn’t equipped to handle just any arbitrary Xml. Still, couldn’t we get some sort of error check in there? Maybe it could just return ValueTree::invalid when it doesn’t work instead of crashing?

It should never crash - if you can find some example input that causes an internal problem in the parser, please either share the stack trace or send us the source data so we can try it ourselves!

Will do! Unfortunately I don’t have a file handy that will crash it, but next time it happens I’ll toss it your way. I’ve been seeing the issue from time to time for a couple years.


Aha! Actually, I suspect I was handing the function a nullptr (createXml from some invalid xml doc, and then passing that in).

Could be wrong, but that’s the issue I see now. Could put a quick return in there for that case, just to catch dumbies like me :slight_smile:

Thanks ~