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

BZFS World Construction calls member functions on NULL object #341

Open
bz-next opened this issue Feb 27, 2024 · 0 comments
Open

BZFS World Construction calls member functions on NULL object #341

bz-next opened this issue Feb 27, 2024 · 0 comments

Comments

@bz-next
Copy link

bz-next commented Feb 27, 2024

BZWReader.cxx:499 inside WorldInfo* BZWReader::defineWorldFromFile():

    if (!BZDB.isTrue("noWalls"))
        makeWalls();

makeWalls() is global and defined in bzfs.cxx:

void makeWalls ( void )
{
    float worldSize = BZDBCache::worldSize;
    if (pluginWorldSize > 0)
        worldSize = pluginWorldSize;
...
        world->addWall(0.0f, 0.5f * worldSize, 0.0f, (float)(1.5 * M_PI), 0.5f * worldSize, wallHeight);
        world->addWall(0.5f * worldSize, 0.0f, 0.0f, (float)M_PI, 0.5f * worldSize, wallHeight);
        world->addWall(0.0f, -0.5f * worldSize, 0.0f, (float)(0.5 * M_PI), 0.5f * worldSize, wallHeight);
        world->addWall(-0.5f * worldSize, 0.0f, 0.0f, 0.0f, 0.5f * worldSize, wallHeight);
    }
}

The trouble is, world is still uninitialized because world is initialized in, for example, bzfs.cxx:1128

        BZWReader* reader = new BZWReader(std::string(worldData.worldFile.c_str()));
        world = reader->defineWorldFromFile();
        delete reader;

Likely, this doesn't crash because world->addWall() doesn't actually attempt to access any instance data, and instead just adds walls to the global obstacle manager.

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