aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2023-06-22 11:55:08 +0200
committerOliver Smith <osmith@sysmocom.de>2023-06-22 11:56:11 +0200
commitd0980a4e8b1e1a1db8bece18c31ecfd3b13cc8b9 (patch)
tree815272be721c5563d74f36881f83605ce8a7dafc
parent79d824f7f4ab50a5b312c80b0e1b82f9453e9689 (diff)
sdp_msg_test: fix dereference after null check
Fixes: CID#274690 Change-Id: Ic59252e4f1d4daf5f86c6b73ec951e02109df9bc
-rw-r--r--tests/sdp_msg/sdp_msg_test.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/sdp_msg/sdp_msg_test.c b/tests/sdp_msg/sdp_msg_test.c
index ebe832848..4798ae007 100644
--- a/tests/sdp_msg/sdp_msg_test.c
+++ b/tests/sdp_msg/sdp_msg_test.c
@@ -526,6 +526,8 @@ static void test_select()
struct sdp_msg sdp = {};
struct sdp_audio_codec *codec;
char buf[1024];
+ const char *expect_sdp;
+
printf("\n[%d]\n", i);
rc = sdp_msg_from_sdp_str(&sdp, t->sdp);
if (rc) {
@@ -542,14 +544,15 @@ static void test_select()
printf("SDP: %s\n", sdp_audio_codecs_to_str(&sdp.audio_codecs));
sdp_msg_to_sdp_str_buf(buf, sizeof(buf), &sdp);
- if (strcmp(buf, t->expect_sdp ? : t->sdp)) {
+ expect_sdp = t->expect_sdp ? : t->sdp;
+ if (strcmp(buf, expect_sdp)) {
int j;
ok = false;
printf("ERROR:\n");
dump_sdp(buf, "selection result: ");
- dump_sdp(t->expect_sdp, "expect result: ");
- for (j = 0; t->expect_sdp[j]; j++) {
- if (t->expect_sdp[j] != buf[j]) {
+ dump_sdp(expect_sdp, "expect result: ");
+ for (j = 0; expect_sdp[j]; j++) {
+ if (expect_sdp[j] != buf[j]) {
printf("ERROR at position %d, at:\n", j);
dump_sdp(buf + j, " mismatch: ");
break;