Bug in libgmm?

View: New views
4 Messages — Rating Filter:   Alert me  

Bug in libgmm?

by Don Weeks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Given these 3 functions:

struct gps_data_t* gpsmm::open(void) {
      return open("127.0.0.1",DEFAULT_GPSD_PORT);
}

struct gps_data_t* gpsmm::open(const char *host, const char *port) {
    gps_data=gps_open(host,port);
    if (gps_data==NULL) { //connection not opened
             return NULL;
    }
    else { //connection succesfully opened
      to_user= new struct gps_data_t;
      return backup(); //we return the backup of our internal structure
    }
}
gpsmm::~gpsmm() {
if (gps_data!=NULL) {
        gps_close(gps_data);
        delete to_user;
}
}

Using the default open causes a core dump on close because gps_data is
not null but is also uninitialized and points to bogus memory. It
seems this may be incorrectly coded. At least in the open(void)
function. Or am I using the default open incorrectly.
Don
_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev

Re: Bug in libgmm?

by Eric Raymond-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don Weeks <don.l.weeks.jr@...>:

> Given these 3 functions:
>
> struct gps_data_t* gpsmm::open(void) {
>       return open("127.0.0.1",DEFAULT_GPSD_PORT);
> }
>
> struct gps_data_t* gpsmm::open(const char *host, const char *port) {
>     gps_data=gps_open(host,port);
>     if (gps_data==NULL) { //connection not opened
>              return NULL;
>     }
>     else { //connection succesfully opened
>       to_user= new struct gps_data_t;
>       return backup(); //we return the backup of our internal structure
>     }
> }
> gpsmm::~gpsmm() {
> if (gps_data!=NULL) {
>         gps_close(gps_data);
>         delete to_user;
> }
> }
>
> Using the default open causes a core dump on close because gps_data is
> not null but is also uninitialized and points to bogus memory. It
> seems this may be incorrectly coded. At least in the open(void)
> function. Or am I using the default open incorrectly.
> Don

No, I agree, that looks incorrect.  Do you have a patch to suggest?
--
                <a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev

Re: Bug in libgmm?

by Don Weeks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

BTW, I wanted to say thanks for working so hard on this software. It's
a real boon to me and the more I use it, the more I like it.

The constructor should set gps_data to NULL to initialize it since
that is the assumption anyway. That should fix it.
          Don

gpsmm() { gps_data = NULL; };


>
> No, I agree, that looks incorrect.  Do you have a patch to suggest?
> --
>                <a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
> _______________________________________________
> Gpsd-dev mailing list
> Gpsd-dev@...
> https://lists.berlios.de/mailman/listinfo/gpsd-dev
>
_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev

Re: Bug in libgmm?

by Eric Raymond-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don Weeks <don.l.weeks.jr@...>:
> BTW, I wanted to say thanks for working so hard on this software. It's
> a real boon to me and the more I use it, the more I like it.

Thanks, we enjoy working on it.
 
> The constructor should set gps_data to NULL to initialize it since
> that is the assumption anyway. That should fix it.
>           Don
>
> gpsmm() { gps_data = NULL; };

Done.
--
                <a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev