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

Should object_make_string check for NULL input string? #10

Open
ghost opened this issue Oct 25, 2021 · 9 comments
Open

Should object_make_string check for NULL input string? #10

ghost opened this issue Oct 25, 2021 · 9 comments

Comments

@ghost
Copy link

ghost commented Oct 25, 2021

Currently, I get a crash at

ape/ape.c

Lines 10208 to 10209 in d4a0c5c

object_t object_make_string(gcmem_t *mem, const char *string) {
int len = (int)strlen(string);
because I sometimes may pass NULL to the string parameter, and strlen crashes on NULL input on Ubuntu 16.04, should this part of code maybe do a check

object_t object_make_string(gcmem_t *mem, const char *string) {
    if (string == NULL) {
        return object_make_null();
    }
    int len = (int)strlen(string);

to handle non-expected NULL gracefully without crashing? :)

Thanks! Ape is great, I'm having a blast with it!

@kgabis
Copy link
Owner

kgabis commented Oct 26, 2021

Hi, I will add this next time I change something in ape, for now please add null checks in you code :)

Mind if I ask what are using ape for? And what do you find good or bad in it so far?

@ghost
Copy link
Author

ghost commented Oct 26, 2021

I'm currently using it to wrap my C framework so I could prototype 2D and 3D programs faster. Work in progress. :)

@ghost
Copy link
Author

ghost commented Oct 26, 2021

I only miss C-like enums, other than that it's great so far! :)

@ghost
Copy link
Author

ghost commented Oct 26, 2021

Just thought I guess one can emulate enums with code like this for now. :)

const MY_ENUM_VALUE = 42

@ghost
Copy link
Author

ghost commented Nov 11, 2021

Released! 🎉 ☺️

https://github.com/procedural/gamescript

@ghost
Copy link
Author

ghost commented Nov 11, 2021

(Game Script also includes my profile library, so it'll be super easy now to profile Ape's perf!)

@kgabis
Copy link
Owner

kgabis commented Nov 12, 2021

Fantastic work! Have you considered open sourcing the code?

@ghost
Copy link
Author

ghost commented Nov 12, 2021

Fantastic work!

Thank you!

Have you considered open sourcing the code?

No, not really, at least not for now.

@darltrash
Copy link

I really like the idea of enums built into the language, perhaps a switch statement too, with simple checks for each case

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

2 participants