cubiomes icon indicating copy to clipboard operation
cubiomes copied to clipboard

Forgot to check nullptr? Or is it intentional?

Open TheBjoel2 opened this issue 1 year ago • 2 comments

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?

TheBjoel2 avatar Dec 08 '24 20:12 TheBjoel2