Skip to content

Commit ef9d908

Browse files
committed
Fix leaky heap allocated objects
1 parent 8efd7f4 commit ef9d908

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ArduinoCellular.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,23 @@ int ArduinoCellular::getSignalQuality(){
166166
}
167167

168168
TinyGsmClient ArduinoCellular::getNetworkClient(){
169-
return TinyGsmClient(modem);
169+
return TinyGsmClient(modem, 0);
170170
}
171171

172172
HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){
173-
return HttpClient(* new TinyGsmClient(modem), server, port);
173+
TinyGsmClient client = getNetworkClient();
174+
return HttpClient(client, server, port);
174175
}
175176

176177
#if defined(ARDUINO_CELLULAR_BEARSSL)
177178
HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
178-
return HttpClient(* new BearSSLClient(* new TinyGsmClient(modem)), server, port);
179+
BearSSLClient client = getSecureNetworkClient();
180+
return HttpClient(client, server, port);
179181
}
180182

181183
BearSSLClient ArduinoCellular::getSecureNetworkClient(){
182-
return BearSSLClient(* new TinyGsmClient(modem));
184+
TinyGsmClient client = getNetworkClient();
185+
return BearSSLClient(client);
183186
}
184187
#endif
185188

0 commit comments

Comments
 (0)