Closed x42 closed 10 months ago
While this is an API user error [...]
Technically true, but it sucks that there's no tooling for this. Maybe I should add clang nullability attributes to lilv.h, I've been using them "internally" for ages and it's pretty great, this kind of "oops I passed NULL and shouldn't have" issue more or less goes away entirely (replaced with an obvious compiler warning), for stuff you can compile on clang anyway (and it forces it to be strictly "documented" in any case).
I haven't been messing with the lilv API much since I hope to largely replace it, but come to think of it, this would be better to do before changing anything in the API since it makes migration much easier (annoying that it could just use ZIX_NONNULL
and friends, but I'm not sure about publicly exposing the zix dependency yet, what that would mean for versioning etc). I wouldn't be surprised if it catches similar bugs in Ardour and other hosts right now... I'll tinker
Ardour passes a valid path, it just happens to not exist on disk [yet].
It's only later, due to zix using realpath
when it becomes NULL, so nullability in lilv.h won't help.
I see. This extra shouldn't be happening already then.
I think it's an annotation "bug" in zix: zix_canonical_path
should return ZIX_NULLABLE
, not ZIX_ALLOCATED
(which effectively means "don't worry/warn about it") but this returns NULL not just on failed allocation, as in this case.
The same is true for zix_create_temporary_directory
. I didn't have filesystem errors in my head when I was annotating those I suppose.
Riiight, I got confused why fixing that caught other similar mistakes in state.c but not this one: the clang, er, "suite" is a bit weird. This is caught by the compiler warning -Wnullable-to-nonnull-conversion
(which was suppressed in lilv), but other more tricky ones are caught by the generally smarter clang-tidy
(which won't report them if you have the clang diagnostic off).
So! Yep, some NULL handling regressions from the zix change. I'll fix this, and all the others, bringing lilv into the "zero null derefence bugs" party of all its dependencies.
Fixed in 81bd78d
While this is an API user error (meanwhile fixed in Ardour), passing a non-existent path to
lilv_state_new_from_file
, crashes lilv since lilv v0.24.20-10 dd5e851.zix_canonical_path
returns NULL if the path passed to it does not exist. This leads to a crash inserd_node_new_file_uri
callingstrlen((const char*)path)
Older versions of liblilv are not affected
lilv_path_absolute
never returned NULL.