Fix randomly broken mlt_repository with relocatable flag #1031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on our automated render tests suite, I came across seemingly random failures rendering with our AppImage with an error message like:
mlt_repository_init: no plugins found in "
/$HOME/git/kdenlive-test-suite/squashfs-root/usr/bin/lib/mlt-7
"Looking into the details, I realized that the path set for
mlt_repository_init
was randomly incorrect when MLT is compiled with the relocatable flag.Turns out the
readlink
[1] method used to retrieve the current path returns a string that is not terminated by a null character, so some garbage was appended to the path. Currently, the path returned by readlink looks like:/$HOME/git/kdenlive-test-suite/squashfs-root/usr/bin/melt-7�N� or
/$HOME/git/kdenlive-test-suite/squashfs-root/usr/bin/melt-7�n/@�~
Whenever a slash happens to be in these garbage chars, the path points to the wrong folder.
This patch ensures the string return by readlink is correctly terminated.
[1] https://github.com/mltframework/mlt/blob/master/src/framework/mlt_factory.c#L156