[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnokii] 01/01: nk6510: fix memory leak caused by acc17a4fe
From: |
Pawel Kot |
Subject: |
[gnokii] 01/01: nk6510: fix memory leak caused by acc17a4fe |
Date: |
Thu, 11 May 2017 07:46:44 -0400 (EDT) |
pkot pushed a commit to branch master
in repository gnokii.
commit ae49546c499665e3af3d365a1ad264f1a391ee06
Author: Ladislav Michl <address@hidden>
Date: Sun Jan 15 11:35:44 2017 +0100
nk6510: fix memory leak caused by acc17a4fe
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 584896b..679f1dc 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