ioquake / ioq3

The ioquake3 community effort to continue supporting/developing id's Quake III Arena
https://ioquake3.org/
GNU General Public License v2.0
2.42k stars 529 forks source link

Fix uninitialized variable in ColorBytes #546

Closed Pan7 closed 2 years ago

Pan7 commented 2 years ago

See https://github.com/ioquake/ioq3/issues/459

zturtleman commented 2 years ago

The loops to fill the rest of the bytes in the unsigned value seems like overkill to me. If size of int/unsigned is not four bytes, lots of stuff will break. The solution would probably be sized types like uint32_t, not supporting 8-byte int or whatever everywhere which would also break file formats, VM APIs, and networking.

I don't think there is an issue with ColorBytes4() which sets all four bytes.

All ColorBytes3 would need to do is set the fourth byte:

( (byte *)&i )[3] = 0;

However nothing uses ColorBytes3() so it could be removed instead.

Pan7 commented 2 years ago

Setting the fourth byte is probably better altought the compiler optimizes the other code. Closing this pr