Skip to content
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

Error on mrb_str_cat function (str_buf_cat) #3574

Closed
rmalizia44 opened this issue Apr 2, 2017 · 3 comments
Closed

Error on mrb_str_cat function (str_buf_cat) #3574

rmalizia44 opened this issue Apr 2, 2017 · 3 comments

Comments

@rmalizia44
Copy link
Contributor

@rmalizia44 rmalizia44 commented Apr 2, 2017

Everytime I create a Ruby String and call mrb_str_cat it gives a Segmentation Fault (using Linux Ubuntu).

Example Code:

mrb_value new_obj = mrb_obj_new(mrb, mrb->string_class, 0, NULL);
const char* test_str = "test";
new_obj = mrb_str_cat(mrb, new_obj, test_str, 4);

I reverted str_buf_cat master to 1.2.0 on "string.c" and the Segmentation Fault stopped.

@fundamental
Copy link
Contributor

@fundamental fundamental commented Apr 2, 2017

Just a guess, but that sounds like new_obj is not fully initialized. Perhaps try using mrb_str_new_lit() to initialize it.

@matz
Copy link
Member

@matz matz commented Apr 3, 2017

Yes, use mrb_str_new* to create string objects.

@rmalizia44
Copy link
Contributor Author

@rmalizia44 rmalizia44 commented Apr 3, 2017

mrb_str_new worked! Thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants