Re: dh_insert: bad deref in chain for ...
Ralph Corderoy <[email protected]>
| Newsgroups | gmane.network.sn |
|---|---|
| Message-ID | <[email protected]> |
Hi Chris,
> len = sizeof (struct chain) + strlen(dp->messageid) + 1 - sizeof (chp->messageid);
>
> But if chp is NULL, this will end the while loop and the next
> statement should segfault because of 'sizeof(chp->messageid)',
> shouldn't it?
`sizeof' isn't a run-time function but a compile-time operator. What
chp points to doesn't affect the size of chp->messageid. This is useful
because it allows
sizeof(((foo *)NULL)->bar)
without having to have a variable of type `foo' to hand, e.g. in a
preprocessor macro definition.
Cheers,
Ralph.