Bug#931977: startpar: uninitialized variable

Dmitry Bogatov KAction at debian.org
Fri Jul 19 14:01:26 BST 2019


[2019-07-17 19:41] Jesse Smith <jsmith at resonatingmedia.com>

> I have added an initialization for the "tail" variable. I also make the
> error more verbose and put in an exit() call in case we are unable to
> allocate any memory. It's a bit crude, but I figure if we ever run into
> a situation where we can't allocate a tiny structure, the system has
> bigger issues to deal with.

Sounds reasonable, thanks.

> In this case I don't think malloc(sizeof(*tail)) will work as that would
> only allocate the size of the pointer rather than the full structure
> (struct console).

Nope. With declaration

	struct console *tail;

`tail' is pointer, sizeof(tail) == sizeof(void*); but sizeof(*tail) is
size of `struct console`.

Actually, it is common idiom to write `sizeof(*tail)' instead
`sizeof(struct console)' to reduce risk of bugs in case type of `tail'
is changed.

> In principle, I agree malloc() is the cleaner function, but I'm going
> to leave the original as it seems to be doing the job without any
> problems.

Fine.
-- 
Note, that I send and fetch email in batch, once in a few days.
Please, mention in body of your reply when you add or remove recepients.




More information about the Debian-init-diversity mailing list