4 ms·
> It still does, because it future proofs you against a change in the future that separates the allocation from completely filling the memory, and saves you fro
by zAy0LfpBZLC8mAC 11y ago
> It still does, because it future proofs you against a change in the future that separates the allocation from completely filling the memory, and saves you from future programmers who don't realize that only half-filling the memory could have catastrophic security or correctness consequences.
But how does replacing that radioactive waste (neat analogy) with zeros improve correctness here?
- IshKebab 11y agoZeros are usually less dangerous than random data - think null terminated strings, memory offsets, etc.
- AnimalMuppet 11y agoOr even null pointer dereferences to wake you up to the fact that you have a problem.
- zAy0LfpBZLC8mAC 11y agoWhich is all to say: It doesn't improve correctness at all. You improve correctness by making your interface difficult to use incorrectly, not by limiting the bad effects of incorrect usage. And any time your code accesses memory that is for all intents and purposes undefined (which it still is, even if you overwrite it with zeros that have no semantic intention behind them), your code is behaving incorrectly by definition.
- vardump 11y agoIt's situational. Sometimes non-zero values crash you faster.
- masklinn 11y ago> But how does replacing that radioactive waste (neat analogy) with zeros improve correctness here? It doesn't improve correctness it limits liability of incorrect code.