From 990eaed4ad579edd04c15186786cc29e9c403d6b Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Tue, 10 Sep 2024 11:04:52 +0200 Subject: [PATCH] [core] Fixed initialization problem in SocketKeeper version with acquire (#3026). --- srtcore/api.h | 4 ++++ test/test_bonding.cpp | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/srtcore/api.h b/srtcore/api.h index b5d6be915..48e7827f8 100644 --- a/srtcore/api.h +++ b/srtcore/api.h @@ -486,7 +486,11 @@ class CUDTUnited bool acquire(CUDTUnited& glob, CUDTSocket* s) { if (s == NULL) + { + socket = NULL; return false; + } + const bool caught = glob.acquireSocket(s); socket = caught ? s : NULL; return caught; diff --git a/test/test_bonding.cpp b/test/test_bonding.cpp index 3aba0b695..0e48c8a04 100644 --- a/test/test_bonding.cpp +++ b/test/test_bonding.cpp @@ -547,14 +547,17 @@ TEST(Bonding, InitialFailure) char outbuf[1316]; SRT_MSGCTRL mc = srt_msgctrl_default; int recvlen = srt_recvmsg2(gs, outbuf, 1316, &mc); - EXPECT_EQ(recvlen, packet_data.size()); - outbuf[recvlen] = 0; + EXPECT_EQ(recvlen, int(packet_data.size())); - EXPECT_EQ(outbuf, packet_data); + if (recvlen > 0) + { + outbuf[recvlen] = 0; + EXPECT_EQ(outbuf, packet_data); + } EXPECT_EQ(mc.pktseq, lsn_isn); recvlen = srt_recv(gs, outbuf, 80); - EXPECT_EQ(recvlen, SRT_ERROR); + EXPECT_EQ(recvlen, int(SRT_ERROR)); srt_close(gs); srt_close(grp);