Skip to content

Commit

Permalink
[N001] Only delect object if created via new
Browse files Browse the repository at this point in the history
  • Loading branch information
tonhuisman committed Feb 1, 2025
1 parent c4f3a53 commit 3a07319
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/src/NotifierStructs/N001_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

bool NPlugin_001_send(const NotificationSettingsStruct& notificationsettings, String& subject, String& body)
{
bool myStatus = false;
bool failFlag = false;
bool myStatus = false;
bool failFlag = false;
bool deleteClient = true;

WiFiClient *client = nullptr;

Expand All @@ -39,7 +40,8 @@ bool NPlugin_001_send(const NotificationSettingsStruct& notificationsettings, St
secureClient.setCfgTime_fcn(get_build_unixtime);
secureClient.setTrustAnchor(Tasmota_TA, Tasmota_TA_size);
secureClient.setInsecure();
client = &secureClient;
client = &secureClient;
deleteClient = false;
} else {
client = new (std::nothrow) WiFiClient();

Expand Down Expand Up @@ -369,7 +371,8 @@ bool NPlugin_001_send(const NotificationSettingsStruct& notificationsettings, St
}

client->stop();
delete client;

if (deleteClient) { delete client; }

return myStatus;
}
Expand Down

0 comments on commit 3a07319

Please sign in to comment.