gpsd: Backport a memory leak fix

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Adrian Bunk
2019-10-28 00:57:54 +02:00
committed by Khem Raj
parent 18506b797b
commit dc26e0395c
2 changed files with 38 additions and 0 deletions
@@ -0,0 +1,37 @@
From 2a4b3bcde0d73a3a4a6644d5f944ac9d16023ba9 Mon Sep 17 00:00:00 2001
From: Adrian Bunk <bunk@stusta.de>
Date: Mon, 21 Oct 2019 13:53:25 +0300
Subject: gps_shm_close: Free privdata
Previously every open/close cycle leaked privdata.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Gary E. Miller <gem@rellim.com>
Upstream-Status: Backport
---
libgps_shm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libgps_shm.c b/libgps_shm.c
index d93972bba..12bb3760b 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -163,8 +163,12 @@ int gps_shm_read(struct gps_data_t *gpsdata)
void gps_shm_close(struct gps_data_t *gpsdata)
{
- if (PRIVATE(gpsdata) && PRIVATE(gpsdata)->shmseg != NULL)
- (void)shmdt((const void *)PRIVATE(gpsdata)->shmseg);
+ if (PRIVATE(gpsdata)) {
+ if (PRIVATE(gpsdata)->shmseg != NULL)
+ (void)shmdt((const void *)PRIVATE(gpsdata)->shmseg);
+ free(PRIVATE(gpsdata));
+ gpsdata->privdata = NULL;
+ }
}
int gps_shm_mainloop(struct gps_data_t *gpsdata, int timeout,
--
2.20.1
@@ -9,6 +9,7 @@ EXTRANATIVEPATH += "chrpath-native"
SRC_URI = "${SAVANNAH_GNU_MIRROR}/${BPN}/${BP}.tar.gz \
file://0001-SConstruct-prefix-includepy-with-sysroot-and-drop-sy.patch \
file://0001-gps_shm_close-Free-privdata.patch \
"
SRC_URI[md5sum] = "b3bf88706794eb8e5f2c2543bf7ba87b"
SRC_URI[sha256sum] = "27dd24d45b2ac69baab7933da2bf6ae5fb0be90130f67e753c110a3477155f39"