Skip to content

Commit 1c4a5be

Browse files
ozgurkaraaslanOzgurselengalp
authored
fix: memory leak (sixfab#93)
* chore: add macos files to .gitignore * fix: fix memory alloc error with deleting big sized variables when unused * Remove deleting boolean variable --------- Co-authored-by: Ozgur <ozgur@Ozgur-MacBook-Air.local> Co-authored-by: Yasin Kaya <yasinkaya.121@gmail.com>
1 parent 7167ab8 commit 1c4a5be

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pico_lte/modules/auth.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,18 @@ def load_certificates(self):
4646
self.file.delete_file_from_modem("/security/user_key.pem")
4747
# Upload new certificates
4848
self.file.upload_file_to_modem("/security/cacert.pem", cacert)
49+
del cacert
4950
self.file.upload_file_to_modem("/security/client.pem", client_cert)
51+
del client_cert
5052
self.file.upload_file_to_modem("/security/user_key.pem", client_key)
53+
del client_key
5154
except Exception as error:
5255
debug.error("Error occured while uploading certificates", error)
5356
return {"status": Status.ERROR, "response": str(error)}
5457

55-
debug.info("Certificates uploaded secure storage. Deleting from file system...")
58+
debug.info(
59+
"Certificates uploaded secure storage. Deleting from file system..."
60+
)
5661
try:
5762
os.remove("../cert/cacert.pem")
5863
os.remove("../cert/client.pem")
@@ -82,10 +87,16 @@ def load_certificates(self):
8287

8388
if cacert_in_modem and client_cert_in_modem and client_key_in_modem:
8489
debug.info("Certificates found in PicoLTE.")
85-
return {"status": Status.SUCCESS, "response": "Certificates found in PicoLTE."}
90+
return {
91+
"status": Status.SUCCESS,
92+
"response": "Certificates found in PicoLTE.",
93+
}
8694
else:
8795
debug.error("Certificates couldn't find in modem!")
88-
return {"status": Status.ERROR, "response": "Certificates couldn't find in modem!"}
96+
return {
97+
"status": Status.ERROR,
98+
"response": "Certificates couldn't find in modem!",
99+
}
89100
else:
90101
debug.error("Error occured while getting certificates from modem!")
91102
return {

0 commit comments

Comments
 (0)