From 0897de81b0daf3daf087f65f56f6f2f1519c1bf8 Mon Sep 17 00:00:00 2001 From: Mymaqn Date: Fri, 13 Oct 2023 13:25:30 +0200 Subject: [PATCH] Fixed possible memory leak in IedConnection_downloadHandler --- pyiec61850/iec61850.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyiec61850/iec61850.i b/pyiec61850/iec61850.i index 3e18daf7..8ad09df9 100644 --- a/pyiec61850/iec61850.i +++ b/pyiec61850/iec61850.i @@ -24,9 +24,13 @@ static bool IedConnection_downloadHandler(void* parameter, uint8_t* buffer, uint { FILE* fp = (FILE*) parameter; + if(fp == NULL){ + return false; + } if (bytesRead > 0) { if (fwrite(buffer, bytesRead, 1, fp) != 1) { printf("Failed to write local file!\n"); + fclose(fp); return false; } }