[PATCH] nk6510: fix memory leak caused by acc17a4fe

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] nk6510: fix memory leak caused by acc17a4fe

Ladislav Michl
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 <[hidden email]>
---
 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


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users