Skip to content

Commit 6472657

Browse files
committed
Implement simple checks before every delete statement ...
1 parent 5d5bc01 commit 6472657

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/core/mdt_dialout_core.cc

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ void Srv::CiscoStream::Start(
465465
"cisco_stream_status = END");
466466
cisco_stream_status = END;
467467
cisco_resp.Finish(grpc::Status::OK, this);
468-
delete cisco_sstream;
468+
if (cisco_sstream) {
469+
delete cisco_sstream;
470+
cisco_sstream = nullptr;
471+
}
469472
} else {
470473
auto tid = std::this_thread::get_id();
471474
std::stringstream stid;
@@ -807,7 +810,10 @@ void Srv::CiscoStream::Start(
807810
}
808811
cisco_stream_status = PROCESSING;
809812
cisco_replies_sent++;
810-
delete cisco_sstream;
813+
if (cisco_sstream) {
814+
delete cisco_sstream;
815+
cisco_sstream = nullptr;
816+
}
811817
}
812818
} else {
813819
spdlog::get("multi-logger")->debug("[CiscoStream::Start()] "
@@ -857,7 +863,10 @@ void Srv::JuniperStream::Start(
857863
"juniper_stream_status = END");
858864
juniper_stream_status = END;
859865
juniper_resp.Finish(grpc::Status::OK, this);
860-
delete juniper_sstream;
866+
if (juniper_sstream) {
867+
delete juniper_sstream;
868+
juniper_sstream = nullptr;
869+
}
861870
} else {
862871
auto tid = std::this_thread::get_id();
863872
std::stringstream stid;
@@ -962,7 +971,10 @@ void Srv::JuniperStream::Start(
962971
}
963972
juniper_stream_status = PROCESSING;
964973
juniper_replies_sent++;
965-
delete juniper_sstream;
974+
if (juniper_sstream) {
975+
delete juniper_sstream;
976+
juniper_sstream = nullptr;
977+
}
966978
}
967979
} else {
968980
spdlog::get("multi-logger")->debug("[JuniperStream::Start()] "
@@ -1007,7 +1019,10 @@ void Srv::HuaweiStream::Start(
10071019
huawei_resp.Read(&huawei_stream, this);
10081020
huawei_stream_status = PROCESSING;
10091021
huawei_replies_sent++;
1010-
delete huawei_sstream;
1022+
if (huawei_sstream) {
1023+
delete huawei_sstream;
1024+
huawei_sstream = nullptr;
1025+
}
10111026
} else if (huawei_stream_status == PROCESSING) {
10121027
if (huawei_replies_sent == kHuaweiMaxReplies) {
10131028
spdlog::get("multi-logger")->debug("[HuaweiStream::Start()] "
@@ -1216,7 +1231,10 @@ void Srv::HuaweiStream::Start(
12161231
}
12171232
huawei_stream_status = PROCESSING;
12181233
huawei_replies_sent++;
1219-
delete huawei_sstream;
1234+
if (huawei_sstream) {
1235+
delete huawei_sstream;
1236+
huawei_sstream = nullptr;
1237+
}
12201238
}
12211239
} else {
12221240
spdlog::get("multi-logger")->debug("[HuaweiStream::Start()] "

0 commit comments

Comments
 (0)