g_canonicalize_filename should work in linear time complexity
The fuzzer is complaining about this in https://oss-fuzz.com/testcase-detail/4995229954998272.
I've made a patch which works in linear time and is very similar to the solution of #2526 (closed).
The added unit test increases coverage to all lines of the new algorithm, the branch coverage is not complete, but without looking at the assembly (which I didn't) its quite hard to say what those uncovered branches are.