[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH] Prevent client crashes if one calls gps_close() multi
From: |
Robert Norris |
Subject: |
[gpsd-dev] [PATCH] Prevent client crashes if one calls gps_close() multiple times |
Date: |
Sat, 30 Jul 2016 18:08:40 +0000 |
privdata must be explicitly set to NULL after use,
otherwise if gps_close() is (incorrectly) called again before
a new gps_open() then a double free condition can occur.
---
libgps_shm.c | 1 +
libgps_sock.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/libgps_shm.c b/libgps_shm.c
index b256249..a0dfdde 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -60,6 +60,7 @@ int gps_shm_open(struct gps_data_t *gpsdata)
if (PRIVATE(gpsdata)->shmseg == (void *) -1) {
/* attach failed for sume unknown reason */
free(gpsdata->privdata);
+ gpsdata->privdata = NULL;
return -2;
}
#ifndef USE_QT
diff --git a/libgps_sock.c b/libgps_sock.c
index d056515..a7ac672 100644
--- a/libgps_sock.c
+++ b/libgps_sock.c
@@ -118,6 +118,7 @@ int gps_sock_close(struct gps_data_t *gpsdata)
int status;
free(PRIVATE(gpsdata));
+ gpsdata->privdata = NULL;
status = close(gpsdata->gps_fd);
gpsdata->gps_fd = -1;
return status;
--
2.8.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gpsd-dev] [PATCH] Prevent client crashes if one calls gps_close() multiple times,
Robert Norris <=