gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] [PATCH] Prevent client crashes if one calls gps_close() m


From: Gary E. Miller
Subject: Re: [gpsd-dev] [PATCH] Prevent client crashes if one calls gps_close() multiple times
Date: Tue, 2 Aug 2016 16:58:22 -0700

Yo Robert!

Looks good.  Patch applied.

On Sat, 30 Jul 2016 18:08:40 +0000
Robert Norris <address@hidden> wrote:

> 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;




RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        address@hidden  Tel:+1 541 382 8588

Attachment: pgpfu28RLuwrc.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]