gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] nk6510: fix memory leak caused by acc17a4fe


From: Ladislav Michl
Subject: [PATCH] nk6510: fix memory leak caused by acc17a4fe
Date: Sun, 15 Jan 2017 11:35:44 +0100
User-agent: NeoMutt/20161126 (1.7.1)

acc17a4fe: 'nk6510: Export of Sent/OU SMS now include their date/time.'
allocates local gn_timestamp structure with g_malloc (?!) and never
releases it. Put asgts variable on stack.

Signed-off-by: Ladislav Michl <address@hidden>
---
 common/phones/nk6510.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index 584896b5..679f1dc2 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -151,27 +151,26 @@ static void FindMessageDateTime_S40(char *time, const 
char *filename)
 
        char ashex[9];
        time_t asts;
-       gn_timestamp *asgts;
+       gn_timestamp asgts;
 
        strncpy(ashex, &filename[8], 8);
        ashex[8] = 0;
 
        asts = (int)strtol(ashex, NULL, 16);
-       asgts = (gn_timestamp *)g_malloc(sizeof(gn_timestamp));
        struct tm *ascp = gmtime(&asts);
-       // Nokia timestamp start in 1980
+       /* Nokia timestamp start in 1980 */
        ascp->tm_year += 10;
 
        dprintf("timestamp fetched from filename: 0x%s => %d => %s\n", ashex, 
asts, asctime(ascp));
-        asgts->second = ascp->tm_sec;
-        asgts->minute = ascp->tm_min;
-        asgts->hour = ascp->tm_hour;
-        asgts->day = ascp->tm_mday;
-        asgts->month = ascp->tm_mon + 1;
-        asgts->year = ascp->tm_year + 1900;
-        asgts->timezone = 0;
-
-       sms_timestamp_pack(asgts, time);
+       asgts.second = ascp->tm_sec;
+       asgts.minute = ascp->tm_min;
+       asgts.hour = ascp->tm_hour;
+       asgts.day = ascp->tm_mday;
+       asgts.month = ascp->tm_mon + 1;
+       asgts.year = ascp->tm_year + 1900;
+       asgts.timezone = 0;
+
+       sms_timestamp_pack(&asgts, time);
 }
 
 #define ALLOC_CHUNK    128
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]