[asterisk-dev] (unreported) uninitialized: struct ast_sockaddr

Alexander Traud pabstraud at compuserve.com
Tue May 5 08:55:54 CDT 2015

In a patch of mine (DANE for Asterisk 13/chan_sip; available on request), a
char* was added in the struct ast_sockaddr to store the DNSSEC failure
reason (why_bogus). Not to create any memory leaks, this pointer has to be
freed. For this, the pointer must be initialized to NULL, for example via
struct ast_sockaddr variable_name = { 0 }. Otherwise, I create a
segmentation fault because I free a non-valid address. Long story short:

Neither GCC nor Clang are able to find uninitialized structs in Asterisk,
although the warning flag -Wall includes -Wuninitialized. And I played
around with the optimization in CFLAG. Mhm.

What shall I do?
A) Init all ast_sockaddr (and all structures containing ast_sockaddr).
   With the default sample configuration, just 5 files must be changed.
However, I searched with the regular expression "struct [^ ]+ [^*=)]+;" and
found 2408 lines of code in 418 files which may be uninitialized. As an
external project member, I cannot change/commit all of them. For a start,
shall I create issue report just about these 5 files?

B) Change my patch not to use a char* but char[128].

C) ... is there an alternative C?

More information about the asterisk-dev mailing list