Closed winterland1989 closed 4 years ago
Hi @winterland1989 ! Thanks for submitting this, I will have a look at it.
What result would you expect in the first case? "./bar"?
After reading the source, I found in the first case the return value is 0, so it's not cwalk's problem, maybe writing a NULL
byte to the buffer? Anyway please add some documents about this behavior.
The second case is definitely is a bug.
Absolutely, I can reproduce it and will fix it as soon as possible.
As the documentation says, the result should always be null terminated. So both cases were bugs and have been fixed on the master branch. Please let me know if something doesnt work as expected!
Thank you! I have tested the new code, there is still a problem I think: cwk_path_get_relative("./foo", "/bar", ...)
doesn't return 0(which i think it should).
Oh no! you are right - I fixed that as well.
cwk_path_get_relative
is buggy if:cwk_path_get_relative("/foo", "./bar", ...)
, in this casecwk_path_get_relative
return garbage result.cwk_path_get_relative("...", "/", ...)
, in this casecwk_path_get_relative
segfaulted.