miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

[C++] `file.name()` corrupts its arg

Open marcgurevitx opened this issue 1 year ago • 2 comments

p = "a/b/"
file.name p
print "[" + p + "]"  // prints: "[a/b"  -- no closing "]"

marcgurevitx avatar Jul 10 '24 13:07 marcgurevitx

Probably found the trouble maker (from man 3 basename on Linux):

Both dirname() and basename() may modify the contents of path, so it may be desirable to pass a copy when calling one of these functions.

marcgurevitx avatar Jul 10 '24 17:07 marcgurevitx

Yes. strdup() fixed the issue on my machine.

marcgurevitx avatar Jul 10 '24 17:07 marcgurevitx