-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm_name_t clarification #149
Comments
Also, given that this only appears in an example for creating a From the comment in the header where For |
Indeed, the distinction was a bit fuzzy. So in #151, I changed the existing Edit: To clarify, regular names are not supposed to be null-terminated. (Maybe that's a bad idea for message strings, too, but that's perhaps a different question.) |
lgtm. Small bikeshed, I don't think |
Hello,
I stumbled into this problem when using the C-API with WASMTIME.
wasmname_t can be created with
wasm_name_new_from_string
. This function is implemented like so:It copies the terminating
'\0'
, as you can observe from the+1
.It is unclear to me if this is intentional or not (it seems like a good idea to copy the null if what's on the other side is a C++ engine).
However, if what's on the other side is a rust implementation that creates a
&str
from bytes, it creates the string array like this:By passing
"env"
as a parameter you get['e', 'n', 'v', '\0']
.Rust strings and string slices (
&str
) are not null terminated, they have a pointer and a size. And this is where that null terminator becomes a problem, as any comparison would fail due to the extra character.So my question is: Is this by design? Could we change it to not pick up the null at the end?
The text was updated successfully, but these errors were encountered: