Re: Buffer Overflow
From: Goran Larsson (hoh@invalid.invalid)
Date: 04/06/03
- Next message: Jan Engelhardt: "Re: Ncurses color messes up aterm transparency"
- Previous message: Thomas Dickey: "Re: How to make a completely static app"
- In reply to: Bjorn Reese: "Re: Buffer Overflow"
- Next in thread: Bjorn Reese: "Re: Buffer Overflow"
- Reply: Bjorn Reese: "Re: Buffer Overflow"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: hoh@invalid.invalid (Goran Larsson) Date: Sun, 6 Apr 2003 16:12:30 GMT
In article <3E8FF73A.D60E31BB@mail1.stofanet.dk>,
Bjorn Reese <breese@mail1.stofanet.dk> wrote:
> int a = 0; /* Make sure that the value is initialized */
> a = 42; /* Assign the real content to the value */
> If there is a possibility that you will access the variable between the
> two assignments, then it is a good practice to initialize it to zero (or
> some other value).
No. That is bad practice. If there is a possibility that you access an
uninitialized variable then you should figure out why that is. Just
blindly initializing the variable is just a case of cargo cult
programming. Leave the variable uninitialized and use the compiler
(with the needed flags) find the places where the variable is read
before written -- and fix the logic of the program.
-- Göran Larsson http://www.mitt-eget.com/
- Next message: Jan Engelhardt: "Re: Ncurses color messes up aterm transparency"
- Previous message: Thomas Dickey: "Re: How to make a completely static app"
- In reply to: Bjorn Reese: "Re: Buffer Overflow"
- Next in thread: Bjorn Reese: "Re: Buffer Overflow"
- Reply: Bjorn Reese: "Re: Buffer Overflow"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]