test_gsm0808_enc_dec_speech_codec_with_cfg: initialize properly

The uninitialized members of enc_sc sporadically hit address sanitizer failure
during gsm0808_test, like:
../../../../src/libosmocore/src/gsm/gsm0808_utils.c:187:8: runtime error: load of value 13, which is not a valid value for type '_Bool'
../../../../src/libosmocore/src/gsm/gsm0808_utils.c:191:8: runtime error: load of value 119, which is not a valid value for type '_Bool'

How the test survived so long is a mystery to me; as soon as some uninitialized
members would by coincidence not be zero, the test should always have failed at
OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0).

Related: OS#3148
Change-Id: Iaa20c59f624fbdc69a018cabd0f7e9c5a1389519
This commit is contained in:
Neels Hofmeyr 2018-04-15 23:31:47 +02:00
parent db2fa4e0d5
commit c62c934647
1 changed files with 7 additions and 7 deletions

View File

@ -595,17 +595,17 @@ static void test_gsm0808_enc_dec_speech_codec()
static void test_gsm0808_enc_dec_speech_codec_with_cfg()
{
struct gsm0808_speech_codec enc_sc;
struct gsm0808_speech_codec dec_sc;
struct gsm0808_speech_codec enc_sc = {
.pi = true,
.tf = true,
.type = GSM0808_SCT_FR3,
.cfg = 0xabcd,
};
struct gsm0808_speech_codec dec_sc = {};
struct msgb *msg;
uint8_t rc_enc;
int rc_dec;
enc_sc.pi = true;
enc_sc.tf = true;
enc_sc.type = GSM0808_SCT_FR3;
enc_sc.cfg = 0xabcd;
msg = msgb_alloc(1024, "output buffer");
rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc);
OSMO_ASSERT(rc_enc == 5);