Skip to content

Commit

Permalink
[core] Fixed wrong filling group data (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris committed Jul 30, 2020
1 parent c05a78c commit d2f0e8a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12664,21 +12664,34 @@ void CUDTGroup::fillGroupData(
const SRT_MSGCTRL& in // MSGCTRL read from the data-providing socket
)
{
// Preserve the data that will be overwritten by assignment
SRT_SOCKGROUPDATA* grpdata = w_out.grpdata;
size_t grpdata_size = w_out.grpdata_size;

w_out = in; // NOTE: This will write NULL to grpdata and 0 to grpdata_size!

w_out.grpdata = NULL; // Make sure it's done, for any case
w_out.grpdata_size = 0;

// User did not wish to read the group data at all.
if (!grpdata)
{
w_out.grpdata = NULL;
w_out.grpdata_size = 0;
return;
}

int st = getGroupData((grpdata), (&w_out.grpdata_size));
// On error, rewrite NULL.
w_out.grpdata = st != SRT_ERROR ? grpdata : NULL;
int st = getGroupData((grpdata), (&grpdata_size));

// Always write back the size, no matter if the data were filled.
w_out.grpdata_size = grpdata_size;

if (st == SRT_ERROR)
{
// Keep NULL in grpdata
return;
}

// Write back original data
w_out.grpdata = grpdata;
}

struct FLookupSocketWithEvent
Expand Down

0 comments on commit d2f0e8a

Please sign in to comment.