Devilution: Usage of an uninitialized variable

Created on 29 Jun 2019  路  6Comments  路  Source: diasurgical/devilution

The pdir variable here:
https://github.com/diasurgical/devilution/blob/a7788ccddf383bb0a1d124b876e841826de15b10/Source/drlg_l3.cpp#L783

... is used without initialization. Visual Studio detected this at runtime. Setting it to zero does not appear to break anything. I don't know if that's correct, though.

Most helpful comment

It breaks bin-exactness, i.e. makes it not like it was written originally. Should be marked as BUGFIX in Devilution and fixed in DevilutionX probably.

All 6 comments

It breaks bin-exactness, i.e. makes it not like it was written originally. Should be marked as BUGFIX in Devilution and fixed in DevilutionX probably.

After some testing it appears that it's always 0 on the stack anyway, but it should definitely have been initialized. The value pdir (previous dir) is compared to 0/1/2/3, so probably should init with -1 to be safe and then on first pass it gets set to dir. Fixing this bug doesn't appear to change map generation.

Maybe this can be done via an ifdef? Is there some macro that distinguishes binary-exact builds?

We will probably just add a BUGFIX comment like we have been doing elsewhere. There are quite a few other bugs, mostly minor, and the comment describes how to fix them.

Thanks. This can be closed then, I suppose.

Yeah things like this should be fixed in devilutionx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AJenbo picture AJenbo  路  7Comments

AJenbo picture AJenbo  路  4Comments

maristane picture maristane  路  3Comments

AJenbo picture AJenbo  路  8Comments

utilForever picture utilForever  路  4Comments