Skip to content

Commit

Permalink
802.11: Fixed various memory leaks detected by sanitizer tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Oct 18, 2024
1 parent 1cd9b16 commit e5d1acf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,16 @@ const Ieee80211HtMode *Ieee80211HtCompliantModes::getCompliantMode(const Ieee802
Ieee80211Htmcs::~Ieee80211Htmcs()
{
delete code;
delete stream1Modulation;
delete stream2Modulation;
delete stream3Modulation;
delete stream4Modulation;
}

Ieee80211HtSignalMode::~Ieee80211HtSignalMode()
{
delete code;
delete modulation;
}

const DI<Ieee80211Htmcs> Ieee80211HtmcsTable::htMcs0BW20MHz([](){ return new Ieee80211Htmcs(0, &BpskModulation::singleton, &Ieee80211OfdmCompliantCodes::ofdmConvolutionalCode1_2, MHz(20));});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class INET_API Ieee80211OfdmModulation : public IModulation
public:
Ieee80211OfdmModulation(int numSubcarriers, const ApskModulationBase *subcarrierModulation);

virtual cObject *dup() const override { return new Ieee80211OfdmModulation(numSubcarriers, subcarrierModulation); }

virtual int getNumSubcarriers() const { return numSubcarriers; }
const ApskModulationBase *getSubcarrierModulation() const { return subcarrierModulation; }

Expand Down
22 changes: 15 additions & 7 deletions src/inet/physicallayer/wireless/ieee80211/mode/Ieee80211VhtMode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ Ieee80211Vhtmcs::Ieee80211Vhtmcs(unsigned int mcsIndex, const ApskModulationBase
bandwidth(bandwidth)
{
if (nss > 1)
stream2Modulation = stream1Modulation;
stream2Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 2)
stream3Modulation = stream1Modulation;
stream3Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 3)
stream4Modulation = stream1Modulation;
stream4Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 4)
stream5Modulation = stream1Modulation;
stream5Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 5)
stream6Modulation = stream1Modulation;
stream6Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 6)
stream7Modulation = stream1Modulation;
stream7Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
if (nss > 7)
stream8Modulation = stream1Modulation;
stream8Modulation = static_cast<Ieee80211OfdmModulation *>(stream1Modulation->dup());
code = Ieee80211VhtCompliantCodes::getCompliantCode(convolutionalCode, stream1Modulation, stream2Modulation, stream3Modulation, stream4Modulation, stream5Modulation, stream6Modulation, stream7Modulation, stream8Modulation, bandwidth);
}

Expand Down Expand Up @@ -702,6 +702,14 @@ const Ieee80211VhtMode *Ieee80211VhtCompliantModes::getCompliantMode(const Ieee8
Ieee80211Vhtmcs::~Ieee80211Vhtmcs()
{
delete code;
delete stream1Modulation;
delete stream2Modulation;
delete stream3Modulation;
delete stream4Modulation;
delete stream5Modulation;
delete stream6Modulation;
delete stream7Modulation;
delete stream8Modulation;
}

Ieee80211VhtSignalMode::~Ieee80211VhtSignalMode()
Expand Down

0 comments on commit e5d1acf

Please sign in to comment.