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

Forgot to check nullptr? Or is it intentional? #131

Open
TheBjoel2 opened this issue Dec 8, 2024 · 0 comments
Open

Forgot to check nullptr? Or is it intentional? #131

TheBjoel2 opened this issue Dec 8, 2024 · 0 comments

Comments

@TheBjoel2
Copy link

TheBjoel2 commented Dec 8, 2024

So, you have an allocCache() function in generator.c, which calls calloc:

int *allocCache(const Generator *g, Range r)
{
    size_t len = getMinCacheSize(g, r.scale, r.sx, r.sy, r.sz);
    if (len == 0)
        return NULL;
    return (int*) calloc(len, sizeof(int));
}

calloc sometimes fails to allocate memory (OOM???) and returns null.
I've changed allocCache() function so that it would not perform any allocations and just return null all the time. The example code at README.md failed immediately (segmentation fault) after that. Briefly looking through this project's code, it seems like you don't check this null value anywhere.

Is it intentional or a genuine issue?

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

1 participant