diff options
author | Robert Norris <rw_norris@hotmail.com> | 2016-07-30 18:08:40 +0000 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2016-08-02 16:55:34 -0700 |
commit | 5115c0b90e5d5a2cb2cb45761d0ae535e5b0be52 (patch) | |
tree | 0a9ef10fdbbe3f76e540307589aa8f4d498453ae | |
parent | 471e144832d5d7404f18b94289d4c0c1d56defbc (diff) | |
download | gpsd-5115c0b90e5d5a2cb2cb45761d0ae535e5b0be52.tar.gz |
Prevent client crashes if one calls gps_close() multiple times
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.
Signed-off-by: Gary E. Miller <gem@rellim.com>
-rw-r--r-- | libgps_shm.c | 1 | ||||
-rw-r--r-- | libgps_sock.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/libgps_shm.c b/libgps_shm.c index b256249f..a0dfdde1 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 a634e752..57da2f30 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -119,6 +119,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; |